TileProvider method getTile - need to translate x and y to lat/long

前端 未结 3 776
北荒
北荒 2020-12-08 11:12

I’m porting an iOS app to Android, and using Google Maps Android API v2. The application needs to draw a heatmap overlay onto the map.

So far, it looks

3条回答
  •  一向
    一向 (楼主)
    2020-12-08 12:08

    This worked for me:

    double n = Math.pow(2, zoom);
    double longitudeMin = x/n * 360 -180;
    double lat_rad = Math.atan(Math.sinh(Math.PI * (1 - 2 * y/n)));
    double latitudeMin = lat_rad * 180/Math.PI;
    
    double longitudeMax = (x + 1)/n * 360 -180;
    lat_rad = Math.atan(Math.sinh(Math.PI * (1 - 2 * (y + 1)/n)));
    double latitudeMax = lat_rad * 180/Math.PI;
    

    References: http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames

提交回复
热议问题