I have a problem with google maps v3 zoom_change, as it doesn't solve my need perfectly.
I have 2 unmet requirements:
I need to get the bounds and show points that are inside the bounds after the user clicked in zoom control and zoom has been reajusted in the map. The method zoom_change do it before reajusting zoom, and the bounds aren't the ones I need.
The method zoom_change is called every time, for example, whenever I execute fitBounds or setZoom. I only need it when when zoomcontrol is clicked or when mousewheel is moved.
Is there a solution available in the v3 API for those issues?
Furthermore, the maximum value of Google Maps Zoom level is 22. Therefore, the defined maximum value must be below or equal to 22, which is the default. The minimum value of Zoom Level is 0 by default, it can be changed by the shortcode as well.
Users can zoom the map by clicking the zoom controls. They can also zoom and pan by using two-finger movements on the map for touchscreen devices.
Hold down the control key on your keyboard, and left click and drag. Use the scroll wheel on your mouse to zoom in and out. (Yes, a mouse with a scroll wheel is a big help here.) This gives you complete 3-D viewing.
Listen for the idle event.
From Google Maps Javascript API V3 Reference:
idle: This event is fired when the map becomes idle after panning or zooming.
The event is called zoom_changed
(NOTzoom_change
). The event handler of this event is called AFTER the zoom has changed. It is indeed not straightforward to distnguish the zoom change caused by the user from that one caused by the program. A possible solution is to maintain a "global" variable say userZoom
which denotes whether the user triggered the zoom.
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 call any of the program actions that change the zoom, set userZoom = false
, e.g.
userZoom = false;
map.setZoom(9);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With