getLatitudeE6() 返回错误值
public boolean onTap(GeoPoint p, MapView mapView) {
String msg;
double d1 = p.getLatitudeE6()/1E6;
double d2 = p.getLongitudeE6()/1E6;
String str1 = Location.convert(d1, Location.FORMAT_DEGREES);
String str2 = Location.convert(d2, Location.FORMAT_DEGREES);
msg = "x = "+ p.getLatitudeE6() +
", y = "+ p.getLongitudeE6();
Toast.makeText(MapViewActivity.this, msg, Toast.LENGTH_LONG).show();
return true;
}
我刚刚编写了这段代码来查看手指在 Android 设备上点击的纬度和经度。
我猜我的代码有问题,或者
谷歌提供的函数“getLatitudeE6”有错误。如您所知,纬度仅从 -90 度到 +90 度,但是当我点击安塔里卡周围的位置时
,特别是在下面,我只能看到 -80 度。换句话说,纬度限制在-80 到80
度之间。这是我的错还是谷歌的错?
public boolean onTap(GeoPoint p, MapView mapView) {
String msg;
double d1 = p.getLatitudeE6()/1E6;
double d2 = p.getLongitudeE6()/1E6;
String str1 = Location.convert(d1, Location.FORMAT_DEGREES);
String str2 = Location.convert(d2, Location.FORMAT_DEGREES);
msg = "x = "+ p.getLatitudeE6() +
", y = "+ p.getLongitudeE6();
Toast.makeText(MapViewActivity.this, msg, Toast.LENGTH_LONG).show();
return true;
}
I just made this code to see Latitude and Longitude where a finger tap on android device.
I guess there's a problem in my code or an error in the function 'getLatitudeE6' provided by
google. As you know, latitude only goes from -90 to +90 degrees ,but when I tap the location around
antarica, especially below, I see only -80. In other words, latitude is limited from -80 to 80
degrees. Is this my fault or google's fault?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你检查 API 文档,它会说:
这是因为在两极附近,墨卡托投影会失去准确性。
If you check the API doc it says:
This is because near the poles, the Mercator projection loses accuracy.
你“点击南极洲”,我猜你正在使用 MapView 来获取坐标。 MapView 使用 墨卡托投影 作为地图投影,该投影的一个缺点是它不是在两极周围很有用,在这种情况下您要点击的地方。所以我猜北极和南极根本不在地图上。因此,这是所使用的地图投影的限制。
如果你想要一张好的南极洲地图,你应该使用不同的地图投影,但我不这样做不知道地图视图是否可行。不过我知道你至少可以改变谷歌地图中的地图投影。
You "tap around antarctica", I guess you are using MapView to get the coordinates. MapView is using Mercator projection as map projection, and a drawback with that projection is that it isn't useful around the poles, where you want to tap in this case. So I guess the north pole and south pole isn't even on the map. So this is a limitation with the map projection that is used.
If you want a good map of antarctica, you should use a different map projection, but I don't know if that is possible with map view. However I know that you can change the map projection in Google Maps at least.