Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google maps api 3 如何更改地图(而不是标记)的Google Maps Dragable属性?_Google Maps Api 3_Draggable - Fatal编程技术网

Google maps api 3 如何更改地图(而不是标记)的Google Maps Dragable属性?

Google maps api 3 如何更改地图(而不是标记)的Google Maps Dragable属性?,google-maps-api-3,draggable,Google Maps Api 3,Draggable,在中,我看到有一个方法setDraggable(boolean),可以应用于地图标记。 但是,我想在地图上设置setDraggable为true,而不是在地图标记上。 我已经在mapOptions中将属性draggable设置为false,但我不知道以后如何将其设置为true映射。SetDragable(true)不起作用: // object literal for map options var myOptions = { center: new


在中,我看到有一个方法
setDraggable(boolean)
,可以应用于地图标记。

但是,我想在地图上设置
setDraggable
true
,而不是在地图标记上。

我已经在mapOptions中将属性
draggable
设置为
false
,但我不知道以后如何将其设置为
true
<代码>映射。SetDragable(true)不起作用:

    // 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!
尝试:


我在这一部分输入了我的代码,它在手机和桌面上工作

function initialize()
    {
    var mapProp = {
      center:myCenter,
      zoom:5,
      draggable:false,
      mapTypeId:google.maps.MapTypeId.ROADMAP
      };

地图类中未使用SetDragable

它用于:

标记类
多段线类
多边形类
矩形类圆形类

在您的情况下,您可以简单地使用:

map.draggable = true;

谢谢@Marcelo,成功了!我不知道
setOptions
,也不知道以这种方式访问地图选项有多么容易。@Marcelo,非常感谢!这是不赞成的。看见
map.draggable = true;