在Google Maps API v3中获取自定义图块的中心LatLng点 [英] Get center LatLng point of a custom tile in Google Maps API v3
问题描述
我有一个需要与之交谈的自定义地图类型API。
我想使用Google地图的'tile'功能来获取地图图片。我已经设置了这样的图块: https:/ /developers.google.com/maps/documentation/javascript/examples/maptype-overlay?hl=nl
获取不同tileimages的API需要我每个瓷砖都有一个中心点。
那么我如何获得/计算每个瓷砖的中心LatLng点?
<解决方案
确定我已经计算出来了。
这是我做的。
您为每个图块(x,y)和缩放以及图块大小设置了一个图块坐标。
因此,首先我们创建一个新的Google MapsPoint到平铺的中心点: var centerpoint = new google.maps.Point((coord.x * tileSize)+ (tileSize / 2),((coord.y + 1)* tileSize)+(tileSize / 2));
然后将这些x,y坐标转换为LatLng(转换函数和它后面的数学可以在 http://www.maptiler.org )
所以它实际上很简单...
I've got a custom map type API I need to talk to.
I'd like to get the map images by using the 'tile' function of Google Maps. I've got the tiles setup like this: https://developers.google.com/maps/documentation/javascript/examples/maptype-overlay?hl=nl
The API to get the different tileimages requires me to have a center point for each of the tiles.
So how do I get/calculate the center LatLng point for each tile?
Ok I figured it out.
Here's what I did.
You have a tile coordinate for each tile (x,y) and zoom and a tile size.
So first we make a new Google MapsPoint to the center point of the tile:
var centerpoint = new google.maps.Point((coord.x * tileSize) + (tileSize / 2), ((coord.y + 1) * tileSize) + (tileSize / 2));
Then convert those x,y coordinates to LatLng (conversion functions and the math behind it can be found on http://www.maptiler.org)
So it was actually pretty simple...
这篇关于在Google Maps API v3中获取自定义图块的中心LatLng点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!