在Google地图窗口中查找角落的经纬度 [英] Finding the lat-long of the corners in a Google Maps window
问题描述
使用Google Maps API,我怎样才能获得地图显示区域角落的经纬度?
Using the Google Maps API, how can I get the latitude and longitude of the corners of the map display area?
也就是说,如果我的地图宽度为300px和400px高,我怎么能找到在(0,0)和(300,400)点的纬度经度?
That is, if my map is 300px wide and 400px tall, how can I find the lat-long of the points at (0,0) and (300,400)?
推荐答案
使用 getBounds()。从文档:
Use getBounds(). From the doc:
以地理坐标返回地图视图中可见的矩形区域。
Returns the the visible rectangular region of the map view in geographical coordinates.
该函数返回您想要的值:地图的西南角和东北角。第一对坐标是左下(西南)坐标,第二对坐标是右上(东北)坐标。
That function returns exactly what you want: the southwest and northeast corners of your map. The first pair of coordinates are the lower left (southwest) coordinates and the second pair is the upper right (northeast) coordinates.
这篇关于在Google地图窗口中查找角落的经纬度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!