Search code examples
javaandroidandroid-mapviewlatitude-longitudewgs84

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, 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?


Solution

  • 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.