I want to add codes inside disable() function to disable dragging and zooming in Google maps API v3 by clicking on ‘disable’ button.
<script type="text/javascript">
var map;
function initialize() {
var uluru = new google.maps.LatLng(21, 57);
map = new google.maps.Map(document.getElementById("map"), {
zoom: 6,
center: uluru,
mapTypeId: google.maps.MapTypeId.HYBRID
});
}
function disable(){
}
</script>
<body onload="initialize()" >
<input type="button" id="next" value="disableZoomDrag" onclick="disable()">
</body>
You can use the
setOptions()method on the map object:If this doesn’t prevent zooming, you could always set the minimum and maximum zoom to the current zoom level.
There is also the
disableDefaultUIoption, which probably takes all of these events into account, but it might disable clicking on existing elements.