Reputation: 48025
I'd like to know if the zoom is changed because user change it from mouse/google zoom tool (top left of the map, the zoomControl) or just if change after some functions of google (like directionsDisplay.setDirections, or bounds) :
google.maps.event.addListener(map, 'zoom_changed', function () {
if (CONDITION) {
}
});
Is it possible?
Upvotes: 0
Views: 263
Reputation: 4995
You probably want to listen for the idle
event, which is a "catch all" event, fired after the user pans or zooms (and it's fired only once). There is also a zoom_changed
event, fired when the zoom level changes. See all Map events here.
I'm not aware of a way to "know" if the zooming is from user intervention or from a Google Maps API function, without at least building a custom zoom control.
Upvotes: 0
Reputation: 161404
You can detect if the zoom has changed based on an action your program has taken by setting a global flag when it performs an action that changes the zoom, clear it when that action is complete (either in the zoom_changed event handler or the idle event handler).
If your flag isn't set, the zoom was caused by a user action.
Upvotes: 2