Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Google Maps API] Disable scrollwheel zooming on the map until map area is clicked.
Droid Offline
Android Developer
*******

Postări: 43
29
Alăturat: Dec 2011
Reputație: 0
Aprecieri acordate: 1
Primit 73 aprecier(i) în 17 post(ări)
#1
Information  [Google Maps API] Disable scrollwheel zooming on the map until map area is clicked.
Prevent google maps zooming when scrolling the page for example.
Use the following to enable map zooming only when the map area is clicked/tapped.

1) in map options add:

Javascript Code
scrollwheel: false,


2) after map initializations add (assuming the map variable is called "map"):

Javascript Code
1
2
3
4
5
6
7
google.maps.event.addListener(map, 'click', function(event){
    this.setOptions({scrollwheel:true});
});
		  
google.maps.event.addListener(map, 'mouseout', function(event){
    this.setOptions({scrollwheel:false});  
});


Reference: Google Maps JavaScript API V3 Reference

29-09-2016, 02:51 PM




User(s) browsing this thread: 1 Guest(s)