Google maps api 3 Google Maps ImageMapTypeOptions.getTileUrl转换点并缩放到LatLng
在google maps v3 api中,如何将传递到Google maps api 3 Google Maps ImageMapTypeOptions.getTileUrl转换点并缩放到LatLng,google-maps-api-3,map-projections,Google Maps Api 3,Map Projections,在google maps v3 api中,如何将传递到ImageMapTypeOptions.getTitleUrl的点和缩放转换为LatLng 谢谢 这显示了如何使用可以用其他语言重新实现的代码来完成 const TILE_SIZE = 314; const tileCoordToWorldCoord = ( tileCoord, zoom ) => { const scale = Math.pow( 2, zoom ); const
ImageMapTypeOptions.getTitleUrl
的点
和缩放
转换为LatLng
谢谢 这显示了如何使用可以用其他语言重新实现的代码来完成
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 );
}