mapScrollPrevent is an easy solution to the problem of page scrolling with new "Google Maps Iframe Embed".
This jQuery and Wordpress plugin prevents Google Maps iframe from capturing the mouse's scrolling wheel / touch scrolling behavior wrapping the <iframe> with a transparent <div> on mouse / touch hover, so you must click / tap them to activate the normal navigation.
Check the Live Demo!. Use it, enjoy it and please contribute to make it better.
You can Download a Pre-Release version. If you are finding the wordpress version check the Wordpress Branch
For usage examples check the live demo.
-
Include jQuery and mapScrollPrevent Libs in your html.
<head> // jQuery Google CDN <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js?ver=2.1.3"></script> // mapScrollPrevent rawgit CDN <script type="text/javascript" src="https://cdn.rawgit.com/diazemiliano/mapScrollPrevent/master/dist/mapScrollPrevent.js"></script> </head>
-
Call mapScrollOff including the following code.
<script type="text/javascript"> $(function() { // Only Google Maps Selector var googleMapSelector = "iframe[src*=\"google.com/maps\"]"; $(googleMapSelector).mapScrollPrevent(); }); </script>
-
Edit defaults.
<script type="text/javascript"> $(function() { // Only Google Maps Selector var googleMapSelector = "iframe[src*=\"google.com/maps\"]"; var options = { hoverMessage:"<p>My custom message.</p>" }; $(googleMapSelector).mapScrollPrevent(options); }); </script>
// JavaScript
var options = {
// Custom class for map wrap
wrapClass:"map-wrap",
// Custom class for hover div
overlayClass:"map-overlay",
// Hover Message
overlayMessage:"<p>Has <b>Clic</b> para Navegar el Mapa.</p>",
// Removes mapScroll
stop:false
};The MIT License (MIT)
Copyright (c) 2015 Emiliano Díaz
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
