Reputation: 2363
I have a Google Map working on my site. There is an event handler watching for double clicks, which carries out a custom function. The event is added like this:
google.maps.event.addListener(map, 'dblclick', function(e) {
placeMarker(e.latLng, map);
});
However, since this function allows a user to submit information that is very location specific we want to ensure that the map is at a certain zoom level before allowing this function to run. Is there any way to prevent this function from running unless at the required zoom level?
Even better would be to display a message/alert if not at the proper zoom level, and allow the function if the zoom level is ok.
Upvotes: 0
Views: 793
Reputation: 29529
You can check map zoom level by using getZoom method. Simply you can check it like this.
google.maps.event.addListener(map, 'dblclick', function(e){
if (map.getZoom() < 7) {
alert('Zoom level is not enough to perform this operation.');
return false;
}
placeMarker(e.latLng, map);
});
Upvotes: 2