Finding the lat-long of the corners in a Google Maps window

后端 未结 1 1252
醉酒成梦
醉酒成梦 2020-12-16 14:33

Using the Google Maps API, how can I get the latitude and longitude of the corners of the map display area?

That is, if my map is 300px wide and 400px tall, how can

相关标签:
1条回答
  • 2020-12-16 14:48

    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.

    0 讨论(0)
提交回复
热议问题