Google Maps API v3: Capturing viewport change – use “idle” not “bounds_changed”

When wanting to capture a change in the viewport (e.g. zoom, pan), when using the Google Maps API v3, the obvious event to listen for seems to be “bounds_changed”. However, when dragging the map to pan, this event is fired repeatedly, which, in our case, meant that there hundreds of requests being sent when a user panned.

The solution is to listen for the “idle” event instead, which is only fired when the user has stopped panning/zooming:

google.maps.event.addListener(map, 'idle', function() {
   //Do something when the user has stopped zooming/panning
});

One Reply to “Google Maps API v3: Capturing viewport change – use “idle” not “bounds_changed””

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.