I am using Google Maps API (v3) to draw a few maps on a page. One thing I'd like to do is disable zooming when you scroll the mouse wheel over the map, but I'm unsure how.
I have disabled the scaleControl (i.e. removed the scaling UI element), but this doesn't prevent scroll wheel scaling.
Here is part of my function (it's a simple jQuery plugin):
$.fn.showMap = function(options, addr){
options = $.extend({
navigationControl: false,
mapTypeControl: false,
scaleControl: false,
draggable: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
}, options);
var map = new google.maps.Map(document.getElementById($(this).attr('id')), options);
// Code cut from this example as not relevant
};
For someone that wondering how to disable the Javascript Google Map API
It will enable the zooming scroll if you click the map once. And disable after your mouse exit the div.
Here is some example
Daniel's code does the job (thanks a heap!). But I wanted to disable zooming completely. I found I had to use all four of these options to do so:
See: MapOptions object specification
As of now (October 2017) Google has implemented a specific property to handle the zooming/scrolling, called
gestureHandling
. Its purpose is to handle mobile devices operation, but it modifies the behaviour for desktop browsers as well. Here it is from official documentation:In short, you can easily force the setting to "always zoomable" (
'greedy'
), "never zoomable" ('none'
), or "user must press CRTL/⌘ to enable zoom" ('cooperative'
).I do it with this simple examps
jQuery
CSS
Or use the gmap options
Keep it simple! Original Google maps variable, none of the extra stuff.
In my case the crucial thing was to set in
'scrollwheel':false
in init. Notice: I am usingjQuery UI Map
. Below is my CoffeeScript init function heading: