如何在使用geojson-vt创建的地图上设置最大缩放

时间:2016-11-24 09:56:15

标签: leaflet mapbox geojson mapbox-gl-js

     if(leafletMap == null){

    leafletMap  = L.map('mapDiv')
          .setView(defaultLocation, defaultZoom)

Layer= L.tileLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}")
   .addTo(leafletMap);

    var tileOptions = {
        maxZoom: 20,  // max zoom to preserve detail on
        tolerance: 5, // simplification tolerance (higher means simpler)
        extent: 4096, // tile extent (both width and height)
        buffer: 64,   // tile buffer on each side
        debug: 0,      // logging level (0 to disable, 1 or 2)

        indexMaxZoom: 20,        // max zoom in the initial tile index
        indexMaxPoints: 100000, // max number of points per tile in the index
    };
    //-------------------------------------------------
}

     tileIndex = geojsonvt(data, tileOptions);



    tileLayer = L.canvasTiles()
                  .params({ debug: false, padding: 5 })
                  .drawing(drawingOnCanvas)


    var pad = 0;

    tileLayer.addTo(leafletMap);

我尝试了很多但是无法设置max zoommin zoom。如果有人会帮助我,我会尝试但是它不起作用会很好:

var options = {
      maxZoom: 17,
      minZoom:10
};

leafletMap  = L.map('mapDiv',undefined,options)
          .setView(defaultLocation, defaultZoom)

1 个答案:

答案 0 :(得分:0)

你说这不起作用:

L.map('mapDiv', undefined, options)

但是L.map()工厂的方法签名的Leaflet API documentation clearly states

L.map(id, options)

让我想知道为什么你把undefined置于首位。