Google maps v3 zoom end

I have a problem with google v3 zoom_change maps, as it does not fully satisfy my needs.

I have 2 unmet requirements:

  • I need to get the borders and show the points that are inside the borders after by clicking the mouse button in the zoom control, and the image was displayed on the map. The zoom_change method does this before zooming, and the ratings are not the ones I need.

  • The zoom_change method is called every time, for example, whenever I execute fitBounds or setZoom. I only need this when I click the zoomcontrol button or when moving the mouse.

Is there a solution available in API v3 for these problems?

+4
source share
3 answers

The event is called zoom_changed (NOT zoom_change ). The event handler for this event is called AFTER zooming. In fact, it is not so easy to reveal the change in scale caused by the user from what is caused by the program. A possible solution is to maintain a β€œglobal” variable say userZoom , which indicates whether the user has caused scaling.

 var userZoom = true; // initial value: be prepared for user action // Install listener google.maps.event.addListener(Map.self, 'zoom_changed', function() { if (userZoom) { // the user changed zoom: do what should be done } else { // zoom change caused by a program action: ignore } userZoom = true; // be prepared for the user zoom action }); 

Before you invoke any program actions that change the scale, set userZoom = false , for example

 userZoom = false; map.setZoom(9); 
+6
source

Listen to an unoccupied event.

From the Javascript API V3 API Reference :

idle: this event is fired when the map becomes inactive after panning or zooming.

+4
source

All Articles