I am working on a WordPress site where the authors usually embed Google Maps using iFrames in most posts.
Is there a way to disable the zoom via mouse scroll wheel on all of them using Javascript?
I am working on a WordPress site where the authors usually embed Google Maps using iFrames in most posts.
Is there a way to disable the zoom via mouse scroll wheel on all of them using Javascript?
There is an awesome and easy solution.
You need to add a custom class in your css that sets the pointer events to map canvas to none:
Then, with jQuery, you can add and remove that class based on different events, for example:
I have created an example in jsfiddle, hope that helps!
I'm re-editing the code written by #nathanielperales it really worked for me. Simple and easy to catch but its work only once. So I added mouseleave() on JavaScript. Idea adapted from #Bogdan And now its perfect. Try this. Credits goes to #nathanielperales and #Bogdan. I just combined both idea's. Thank you guys. I hope this will help others also...
HTML
CSS
jQuery
Improvise - Adapt - Overcome
And here is an jsFiddle example.
Variations on a theme: a simple solution with jQuery, no CSS editing needed.
Hover listener is attached to the parent element, so if the current parent is bigger, you can just simply wrap the iframe with a div before the 3rd line.
Hope it'll be useful for somebody.
This will give you a responsive Google Map that will stop the scrolling on the iframe, but once clicked on will let you zoom.
Copy and paste this into your html but replace the iframe link with your own. He's an article on it with an example: Disable the mouse scroll wheel zoom on embedded Google Map iframes
Here's my take on the @nathanielperales answer extended by @chams, now extended again by me.
HTML
jQuery
After doing some research you have 2 options. Since new maps api with iframe embed does not seem to support disabling of mousewheel.
First would be using old google maps ( https://support.google.com/maps/answer/3045828?hl=en ).
Second would be creating a javascript function to simplify embeding of a map for each comment and using parameters (it's sample code only to point location not show exact solution)