In the Google Maps v3 reference, I see there is a method setDraggable(boolean)
which can be applied to a map marker.
However, I want to set setDraggable
to true
on the map, not on a map marker.
I have set the property draggable
to false
in the mapOptions, but I don't know how to set this to true
later... map.setDraggable(true)
does not work:
// object literal for map options
var myOptions =
{
center: new google.maps.LatLng(37.09024, -95.712891),
zoom: 4, // smaller number --> zoom out
mapTypeId: google.maps.MapTypeId.TERRAIN,
// removing all map controls
disableDefaultUI: true,
// prevents map from being dragged
draggable: false,
// disabling all keyboard shortcuts
keyboardShortcuts: false,
disableDoubleClickZoom: true,
// do not clear the map div
noClear: true
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
map.setDraggable(true); // does NOT work!
Open Google Maps. Click Menu Your places Labeled. Next to the label you want to remove, click Remove .
Call the changeMarkerPosition() function and pass the marker object in it. The setPosition() will change the marker position on google map based on the specified latitude and longitude.
Try:
map.setOptions({draggable: true});
I entered my code in this section and it worked on mobile and desktop
function initialize()
{
var mapProp = {
center:myCenter,
zoom:5,
draggable:false,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With