amit hasija
amit hasija

Reputation: 23

how to find minimum & maximum values latitude and longitude on google map

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.

Upvotes: 1

Views: 5849

Answers (2)

Salman Arshad
Salman Arshad

Reputation: 272066

You can hook an event listener for Map -> idle event:

This event is fired when the map becomes 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.

Upvotes: 4

axelarge
axelarge

Reputation: 967

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.com/apis/maps/documentation/javascript/reference.html#Map

Upvotes: 2

Related Questions