I have a contacts page with google map. When user scrolls down map covers full screen on mobile device.
I want to allow users to scroll the map only on click+drag and not on simple scrolling, so that user could scroll out of the map.
Any ideas?
I have a contacts page with google map. When user scrolls down map covers full screen on mobile device.
I want to allow users to scroll the map only on click+drag and not on simple scrolling, so that user could scroll out of the map.
Any ideas?
Two methods i know using Hammer Js to handle the Double Taps.
One is to add an overlay on the map and change its z-index
value as required. The bonus with the overlay is that no additional code is needed to disable any interaction on the map if needed, e.g markers click and controls.
Two is to use the in-build Gmaps .setOptions({draggable: true/false}
function.
Method one Demo Note. Adjust CSS width, height, position for your Map(s)
CSS
.overlay {
position:absolute;
height:300px;
width:100%;
background:transparent;
z-index:99;
top:0;
left:0;
}
Code
mc.on("doubbletap", function(ev) {
$(".overlay").css("z-index", "1");
})
Method Two Demo Using .setOptions({draggable: true/false}
Code
// set map Options to disable drag.
map.setOptions({draggable: false});
// enable drag
mc.on("doubbletap", function(ev) {
map.setOptions({draggable: true});
})