bjorn2404 / jQuery-Store-Locator-Plugin

A store locator plugin using Google Maps API version 3
MIT License
495 stars 235 forks source link

Enable mouse wheel zoom on click #169

Closed 77656233 closed 7 years ago

77656233 commented 7 years ago

Hey guys,

i added this locator to a website project i am on right now and had the problem that i was not able to scroll the page when my mouse was over the map.

I found this site: http://bdadam.com/blog/simple-usability-trick-for-google-maps.html

on the commentars was a usefull function:

function init(){
  map = new google.maps.Map(el[0], {
    zoom: 10,
    center: new google.maps.LatLng(47.49840560, 19.04075779),
    scrollwheel:  false
  });

function enableScrollingWithMouseWheel() {
    map.setOptions({ scrollwheel: true });
}

function disableScrollingWithMouseWheel() {
    map.setOptions({ scrollwheel: false });
}

  // Enable scrolling on click event on the map
  map.addListener('click', enableScrollingWithMouseWheel);

  // Enable scrolling on drag event on the map
  map.addListener('drag', enableScrollingWithMouseWheel);

  // Disable scrolling on mouseout from the map
  map.addListener('mouseout', disableScrollingWithMouseWheel);

}

I now added the "scrollwheel: false" function to my map settings but i was not able to get the other functions included into the code. So right now i just disabled the zoom scroll ;/ but i would love to get it back on click on drag event like the function should work from top.

Can someone help me to get this working?

Greetings Chris

rlandeiro commented 7 years ago

I also have scrolling disabled on my site by using 'mapsettings' parameter:

$('#bh-sl-map-container').storeLocator({ 'mapSettings' : {scrollwheel: false} });

77656233 commented 7 years ago

Yes but if this snipped would be included the right way into the code it would be possible to activate it with a click or drag and drop and it gets disabled again on mouse out of map. So i really hope someone could add it.

bjorn2404 commented 7 years ago

In November of 2016 Google pushed out gestureHandling and from my testing it's set to cooperative by default on mobile devices without updating or changing anything. gestureHandling is a better solution compared to the code above and the above might actually interfere with this functionality so I don't consider it to be an issue and I'm closing this.