在Google Maps v3 reference,我看到有一種方法setDraggable(boolean)
可以應用到地圖標記。
不過,我想設置setDraggable
到true
在地圖上標記的地圖,不上。
我已經財產draggable
設置爲在MapOptions false
,但我不知道如何稍後設置爲true
... map.setDraggable(true)
不不工作:
如何更改地圖的Google Maps可拖動屬性(不是標記)?
// 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!
感謝@Marcelo,該訣竅!我並不知道'setOptions',以這種方式訪問地圖選項是多麼容易。 –
@Marcelo,非常感謝你! –