I want to locate the minimum latitude/longitude & maximum latitude/longitude value of visible region region of Google map.For eg: if i drag the map along any axis than at drag end, java script will alert me with minimum/maximum latitude/longitude values.
I want to locate the minimum latitude/longitude & maximum latitude/longitude value of visible region region of Google map.For eg: if i drag the map along any axis than at drag end, java script will alert me with minimum/maximum latitude/longitude values.
Share Improve this question edited Sep 5, 2011 at 7:24 Tatu Ulmanen 125k34 gold badges189 silver badges185 bronze badges asked Sep 5, 2011 at 7:19 amit hasijaamit hasija 231 silver badge4 bronze badges2 Answers
Reset to default 4You can hook an event listener for Map -> idle event:
This event is fired when the map bees idle after panning or zooming.
Inside that event you can call the Map.getBounds()
method. You can then use the LatLngBounds.getNorthEast()
and LatLngBounds.getSouthWest()
methods to get the top-left and bottom right corners of the visible region.
- Demo here
- google.maps.Map reference
- google.maps.LatLngBounds reference
Use google.maps.Map#getBounds
For example:
var map = new google.maps.Map(document.getElementById('map-div'), { /* options */});
var bounds = map.getBounds();
http://code.google./apis/maps/documentation/javascript/reference.html#Map