谷歌地图ImageMapTypeOptions.getTileUrl将点和缩放转换为LatLng。

问题描述 投票:3回答:2

在google地图v3 api中,我如何转换我的 pointzoom 传到 ImageMapTypeOptions.getTitleUrlLatLng?

谢谢!

google-maps-api-3 map-projections
2个回答
1
投票

这显示了如何用代码来完成,你可以用其他语言重新实现。

https:/developers.google.commapsdocumentationjavascriptexamplesmap-coordinates。


0
投票
    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 );
        }
© www.soinside.com 2019 - 2024. All rights reserved.