getLatitudeE6() returns wrong value
public boolean onTap(GeoPoint p, MapView mapView) {
String msg;
double d1 = p.getLatitudeE6()/1E6;
double d2 = p.getLongitudeE6()/1E6;
String str1 = Location.convert(d1, Loca开发者_高级运维tion.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?
If you check the API doc it says:
Latitude: This will be clamped to between -80 degrees and +80 degrees inclusive, in order to maintain accuracy in the Mercator projection.
This is because near the poles, the Mercator projection loses accuracy.
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.
精彩评论