传单限制视图

时间:2018-10-18 11:53:28

标签: javascript leaflet

是否可以将视图限制在0,0个图块和1000,1000个图块之间?以及如何将地图视图设置为特殊的瓷砖,使他获得X和Y坐标?

示例:

var map = L.map('map', {
    crs: L.CRS.Simple,
    minZoom: -3,
    zoomControl: false,
    maxBoundsViscosity: 0.1
});

map.on('click',function(e){

});

map.touchZoom.disable();
map.doubleClickZoom.disable();
map.scrollWheelZoom.disable();
map.boxZoom.disable();
map.keyboard.disable();


L.TileLayer.V = L.TileLayer.extend({
    createTile: function (coords) {
        var tile = document.createElement('div');
        tile.innerHTML = [coords.x, coords.y].join(', ');
        tile.style.outline = '1px solid red';
        return tile;
    },
    getTileSize: function () {
        return L.point(53, 38)
    },
    setMinZoom: function () {
        return 1
    },
    setMaxZoom: function () {
        return 1
    },
});

L.tileLayer.V = function () {
    return new L.TileLayer.V();
}

L.tileLayer.V().addTo(map);
map.setView([10,10], 1);

现场演示 https://codepen.io/DarHor/pen/WazzLQ

0 个答案:

没有答案