In google maps v3 api, How do I convert the point
and zoom
that get passed to ImageMapTypeOptions.getTitleUrl
to a LatLng
?
Thanks!
In google maps v3 api, How do I convert the point
and zoom
that get passed to ImageMapTypeOptions.getTitleUrl
to a LatLng
?
Thanks!
This shows how it's done with code you can reimplement in other languages.
https://developers.google.com/maps/documentation/javascript/examples/map-coordinates
const TILE_SIZE = 314;
const tileCoordToWorldCoord = ( tileCoord, zoom ) => {
const scale = Math.pow( 2, zoom );
const shift = Math.floor( TILE_SIZE / 2 );
const calc = tc => ( tc * TILE_SIZE + shift ) / scale;
const x = calc( tileCoord.x );
const y = calc( tileCoord.y );
return new google.maps.Point( x, y );
}
...
getTileUrl: ( coord, zoom ) => {
const pointCoord = tileCoordToWorldCoord( coord, zoom );
const latLng = mapInstance.getProjection().fromPointToLatLng( pointCoord );
}