传单如何增加 maxZoom

Leaflet how to increase maxZoom

我在我的应用程序中使用 Leaflet,我需要缩放超过 18 级(我认为 19 或 20 级就足够了)。但是当我缩放超过 18 级时,地图图像消失,只留下一个灰色平面。

这是html:

<div id="map"></div>

这是js:

var options = {
    maxZoom: 19,
    minZoom: 18
};

$timeout(function() {
    $scope.map = L.map('map', options).setView([38.62276209666611, 34.70849695797369], 18);

    L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://www.example.com/">Example</a>'
    }).addTo($scope.map);

    $scope.map.dragging.disable();
});

我已经尝试过这些:

map.options.minZoom = 18;
map.options.maxZoom = 19;

maxNativeZoom.

同时将 maxZoom 设置为 tileLayer

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://www.example.com/">Example</a>',
    maxZoom: 20
}).addTo($scope.map);

maxNativeZoomL.TileLayer的选项,不是L.Map的选项。这是properly documented in the Leaflet reference

See a working example.

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="http://www.example.com/">Example</a>',
        maxNativeZoom:19,
        maxZoom:25
    }).addTo($scope.map);

这是一个Mapbox配置,我发现对我来说最完美的缩放设置是“maxNativeZoom”:19,“maxZoom”:20,你可以增加maxZoom值,但不能增加“maxNativeZoom”值高于 19 因为它会显示灰色方块

L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
            {"attribution": "Mapbox", "detectRetina": false, "maxNativeZoom": 19, "maxZoom": 20, "minZoom": 0, "noWrap": false, "opacity": 1, "subdomains": "abc", "tms": false})