Enable/disable button for scroll wheel

308 views
Skip to first unread message

mateusz

unread,
Apr 20, 2011, 7:19:57 AM4/20/11
to google-map...@googlegroups.com

Hey.

I'm wondering how to make a button which will enable or disable scroll wheel. I'm using the newest API version (v3). Could it work without reloading page?

I have a button:
<input id="scrollButton" type="button" value="Yes">

and script only for changing Button label:

$(document).ready(function() {

$("#scrollButton").click(function() {
if (this.value == "Yes") {
this.value = "No";
//  function will switch off scroll wheel

} else if (this.value == "No") {
this.value = "Yes";
//  function will switch on scroll wheel  
}
});
});
Any ideas? Thanks for help! 

mateusz

unread,
Apr 20, 2011, 7:54:24 AM4/20/11
to google-map...@googlegroups.com
Sorry, I mean without reloading map to default init() settings.

Now it looks like that: (scrollButtonOption is global)

$(document).ready(function() {

$("#scrollButton").click(function() {
if (this.value == "Yes") {
this.value = "No";
scrollButtonOption = null;
init();

} else if (this.value == "No") {
this.value = "Yes";
scrollButtonOption = true;
init();
}
});
});


function init(){
var mapOptions = {
scrollwheel: scrollButtonOption,
...
 

JKurtock

unread,
Apr 20, 2011, 4:27:17 PM4/20/11
to Google Maps JavaScript API v3
Just use the setOptions method of the map object to reload all the
options, including the new scrollwheel option.
http://code.google.com/intl/en/apis/maps/documentation/javascript/reference.html#Map

Douglas Machado

unread,
Jul 20, 2011, 8:47:43 AM7/20/11
to google-map...@googlegroups.com
It would be nice if the scroll-wheel zooming of the map did not activate until the map area is clicked. This makes it easier to scroll through the page without being stopped by the map zooming.

Is there a way to enable scrollwheel zooming only when the user clicks on the map.

Best regards,
Reply all
Reply to author
Forward
0 new messages