Android:Location.distanceTo 无法正常工作?
我在使用 Location.distanceTo
方法计算距离时遇到问题。
private class MyLocationOverlay1 extends MyLocationOverlay {
@Override
public void drawMyLocation(Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when)
super.drawMyLocation(canvas,mapView,lastFix,myLocation,when);
Location bLocation = new Location("reverseGeocoded");
bLocation.setLatitude(FindList.gpslat); // Value = 3.294391E7
bLocation.setLongitude(FindList.gpslong); // Value = -9.6564615E7
Location aLocation = new Location("reverseGeocoded");
aLocation.setLatitude(myLocation.getLatitudeE6()); // Value = 3.2946164E7
aLocation.setLongitude(myLocation.getLongitudeE6()); // Value = -9.6505141E7
aLocation.set(aLocation); // Don't think I need this
bLocation.set(bLocation); // Don't think I need this either
int distance = (int)aLocation.distanceTo(bLocation); // Value = 12637795 ???
String str = " (" + String.valueOf(distance) + " meters)";
}
}
有人可以告诉我为什么我的距离计算结果显示 12,637,795 米吗?
I am having an issue calculating distance using the Location.distanceTo
method.
private class MyLocationOverlay1 extends MyLocationOverlay {
@Override
public void drawMyLocation(Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when)
super.drawMyLocation(canvas,mapView,lastFix,myLocation,when);
Location bLocation = new Location("reverseGeocoded");
bLocation.setLatitude(FindList.gpslat); // Value = 3.294391E7
bLocation.setLongitude(FindList.gpslong); // Value = -9.6564615E7
Location aLocation = new Location("reverseGeocoded");
aLocation.setLatitude(myLocation.getLatitudeE6()); // Value = 3.2946164E7
aLocation.setLongitude(myLocation.getLongitudeE6()); // Value = -9.6505141E7
aLocation.set(aLocation); // Don't think I need this
bLocation.set(bLocation); // Don't think I need this either
int distance = (int)aLocation.distanceTo(bLocation); // Value = 12637795 ???
String str = " (" + String.valueOf(distance) + " meters)";
}
}
Can someone tell my why my distance calculation is showing 12,637,795 Meters?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该修改行:
并删除行:
You should Modify lines:
And remove the lines: