Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 I find the lat-long of the points at (0,0) and (300,400)?

like image 534
Matt Hampel Avatar asked Jul 05 '09 04:07

Matt Hampel


People also ask

What is the coordinate system of Google Maps?

(Google uses the World Geodetic System WGS84 standard.) World coordinates, which reference a point on the map uniquely.


1 Answers

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.

like image 126
Derek Swingley Avatar answered Sep 28 '22 05:09

Derek Swingley