Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
75
rated 0 times [  78] [ 3]  / answers: 1 / hits: 98704  / 10 Years ago, tue, july 15, 2014, 12:00:00

If you're browsing with an embedded maps iframe using your trackpad or mouse, you can potentially trap yourself into the Maps' zooming capabilities, which is really annoying.



Try it here: https://developers.google.com/maps/documentation/embed/guide#overview



Is there a way to prevent this?


More From » jquery

 Answers
30

This has been answered here => Disable mouse scroll wheel zoom on embedded Google Maps by Bogdan. What it does is that it will disable the mouse until you click onto the map and the mouse start working again, if you move the mouse out from the map the mouse will be disabled again.



Note: Does not work on IE < 11 (Working fine on IE 11)



CSS:



<style>
.scrolloff {
pointer-events: none;
}
</style>


Script:



<script>
$(document).ready(function () {

// you want to enable the pointer events only on click;

$('#map_canvas1').addClass('scrolloff'); // set the pointer events to none on doc ready
$('#canvas1').on('click', function () {
$('#map_canvas1').removeClass('scrolloff'); // set the pointer events true on click
});

// you want to disable pointer events when the mouse leave the canvas area;

$(#map_canvas1).mouseleave(function () {
$('#map_canvas1').addClass('scrolloff'); // set the pointer events to none when mouse leaves the map area
});
});
</script>


HTML: (just need to put correct id as defined in css and script)



<section id=canvas1 class=map>
<iframe id=map_canvas1 src=https://www.google.com/maps/embe.... width=1170 height=400 frameborder=0 style=border: 0></iframe>
</section>

[#70195] Saturday, July 12, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bobbidayanam

Total Points: 82
Total Questions: 99
Total Answers: 96

Location: Venezuela
Member since Sat, Apr 24, 2021
3 Years ago
bobbidayanam questions
Sat, Mar 21, 20, 00:00, 4 Years ago
Mon, Dec 24, 18, 00:00, 6 Years ago
Fri, Nov 16, 18, 00:00, 6 Years ago
;