Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
102
rated 0 times [  105] [ 3]  / answers: 1 / hits: 71843  / 13 Years ago, sun, november 20, 2011, 12:00:00

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>

More From » google-maps

 Answers
22

You can use the setOptions() method on the map object:



map.setOptions({draggable: false, zoomControl: false, scrollwheel: false, disableDoubleClickZoom: true});


If this doesn't prevent zooming, you could always set the minimum and maximum zoom to the current zoom level.



There is also the disableDefaultUI option, which probably takes all of these events into account, but it might disable clicking on existing elements.


[#89008] Friday, November 18, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raymondd

Total Points: 620
Total Questions: 112
Total Answers: 94

Location: Namibia
Member since Mon, Feb 21, 2022
2 Years ago
raymondd questions
Thu, Apr 22, 21, 00:00, 3 Years ago
Thu, Jul 9, 20, 00:00, 4 Years ago
Thu, Apr 9, 20, 00:00, 4 Years ago
Thu, Jul 25, 19, 00:00, 5 Years ago
;