2016-02-11 91 views
1

有没有办法让地图的视口锁定(不可拖动)?我有我的网页上的地图,但我仍然可以把它的滚动向上和向下,当我点击并拖动鼠标......制作jVectormap不可拖拽

<div class="map-container"> 
    <div id="nz-map" style="width: 600px; height: 400px"></div> 
</div> 

,并使用JS创建地图

/* map parameters */ 
    var wrld = { 
      map: 'nz_mill_en', 
      backgroundColor: '#fff', 
      regionStyle: { 
     initial: { 
     fill: '#012051' 
     }, 
     hover: { 
      "fill-opacity" : 1 
     }}, 
      onMarkerClick: function(events, index) { 
      $(location).attr('href', markers[index].weburl); 
      }, 
      onRegionLabelShow: function(e, el, code){ 
       e.preventDefault(); 
      }, 
      colors:{ 
     "Northern": '#012051', 
       "East Coast": '#012051', 
       "Central": '#012051', 
       "Upper South Island": '#012051', 
       "South Canterbury": '#012051', 
       "Otago": '#012051', 
       "Southland": '#012051' 
      }, 
      series: { 
     regions: 
     [{ 
     attribute: 'fill' 
     }] 
    }, 
      zoomButtons: false, 
      zoomOnScroll: false, 
      focusOn: { 
       x: 0.3, 
       y: 0.7, 
       scale: 3 
      }, 
      markerStyle: { 
       initial: { 
        fill: '#F8E23B', 
        stroke: '#383f47' 
       } 
      }, 
      markers: markers, 
    }; 

    $('#nz-map').vectorMap(wrld); 

回答

2

您将panOnDrag参数设置为false以禁用地图的平移

var wrld = { 
    map: 'nz_mill_en', 
    backgroundColor: '#fff', 
    panOnDrag: false, // disable panning of the map 
    ... 
} 
+0

完美!欢呼队友 –

+0

你知道吗,有没有办法阻止它在手机上平移?这适用于桌面而不是手机。 –

+0

还想知道如何禁用拖动手机。 –