使jVectormap无法拖动

时间:2016-02-11 21:33:44

标签: javascript jquery 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);

1 个答案:

答案 0 :(得分:2)

您在panOnDrag上设置false参数以禁用地图平移

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