在google地图v3 api中,我如何转换我的 point
和 zoom
传到 ImageMapTypeOptions.getTitleUrl
到 LatLng
?
谢谢!
这显示了如何用代码来完成,你可以用其他语言重新实现。
https:/developers.google.commapsdocumentationjavascriptexamplesmap-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 );
}