Skip to content

Instantly share code, notes, and snippets.

@MAXHEADR0OM
Last active July 25, 2018 14:48
Show Gist options
  • Save MAXHEADR0OM/2edecd2713241d9953bc2d4d60ccd8a4 to your computer and use it in GitHub Desktop.
Save MAXHEADR0OM/2edecd2713241d9953bc2d4d60ccd8a4 to your computer and use it in GitHub Desktop.
Prevent Google Maps Zoom
<div id="map-wrapper">
<iframe id="map-canvas"></iframe>
</div>
// Iframe wrapper ID set to #map-wrapper
// Iframe ID set to #map-canvas
var wrapper = $('#map-wrapper');
var canvas = $('#map-canvas');
// Prevent map zoom on scroll
// Enable the pointer events only on click
// Disable pointer events on doc ready
canvas.addClass('scroll-off');
// Enable pointer events on wrapper click
wrapper.on('click', function () {
canvas.removeClass('scroll-off');
});
// Disable pointer events when the mouse leaves the canvas
canvas.mouseleave(function () {
canvas.addClass('scroll-off');
});
.scroll-off {
pointer-events: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment