Leaflet 传单.js正在尝试加载超出边界的瓷砖

Leaflet 传单.js正在尝试加载超出边界的瓷砖,leaflet,Leaflet,我正在初始化传单,如下所示: var map, imageWidth = 6400, imageHeight = 8000, tileSize = 200; L.tileLayer('tiles/{z}/map_{x}_{y}.png', { minZoom: 17, maxZoom: 20, updateWhenIdle: true,

我正在初始化传单,如下所示:

var map,
    imageWidth  = 6400,
    imageHeight = 8000,
    tileSize    = 200;

L.tileLayer('tiles/{z}/map_{x}_{y}.png', {
                minZoom: 17,
                maxZoom: 20,
                updateWhenIdle: true,
                noWrap: true,
                tileSize: tileSize,
                unloadInvisibleTiles: false,
                reuseTiles: true,
                crs: L.CRS.Simple
              }).addTo(map);

            map.doubleClickZoom.disable();

            var southWest = map.unproject([0, imageHeight], map.getMaxZoom());
            var northEast = map.unproject([imageWidth, 0], map.getMaxZoom());
            map.setMaxBounds(new L.LatLngBounds(southWest, northEast));
我收到以下控制台错误:

GET http://localhost:8000/dist/tiles/17/map_83886_83886.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83885_83886.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83886_83885.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83885_83885.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83885_83887.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83886_83887.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_3_5.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_2_5.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_1_5.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83884_83886.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83887_83886.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83884_83887.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83884_83885.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83887_83885.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_83887_83887.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_4_3.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_4_4.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_4_2.png 404 (Not Found)
map.html:32 GET http://localhost:8000/dist/tiles/17/map_4_5.png 404 (Not Found)
我不太明白为什么图书馆要加载这些瓷砖,因为我已经设置了边界,所以传单不应该尝试加载超出它们的任何内容

我使用map.unproject的方式有什么问题吗?就用户可以在屏幕上拖动图像的距离而言,边界似乎工作得很好


谢谢

来自类型。因此,您必须输入坐标,而不是像示例中那样的像素大小。

传单0.7有一个错误,它试图加载与地图边界接触的分幅,而不仅仅是与边界相交的分幅。这应该在目前处于Beta版本的传单1.0中进行固定。您可以在中查看详细信息

简单的解决方案是通过单个像素调整贴图边界。我发现实际上只需要调整0。因此,不是:

var southWest = map.unproject([0, imageHeight], map.getMaxZoom());
var northEast = map.unproject([imageWidth, 0], map.getMaxZoom());
使用:


如果有人仍然遇到这个问题,我使用@Josh的解决方案解决了这个问题,但也不得不将地图的宽度和高度每边减少2倍,每边减少1倍。所以我的界限是这样的

var southWest = map.unproject([0, 1200], map.getMaxZoom());
var northEast = map.unproject([800, 0], map.getMaxZoom());
致:


好的,谢谢你的回复。我确实删除了maxbounds,只使用了这条线:map.setMaxBoundsnew L.LatLngBoundssouthWest,northEast;但这会导致相同的结果或加载超出边界的图像。你认为map.unproject中发生的任何事情都可能返回错误的值吗?如果你使用的是像素图像,我认为你必须首先转换像素坐标。也许会有帮助。我正在用这个转换像素坐标:新的L.LatLngBoundssouthWest,东北
var southWest = map.unproject([0, 1200], map.getMaxZoom());
var northEast = map.unproject([800, 0], map.getMaxZoom());
var southWest = map.unproject([1, 1198], map.getMaxZoom());
var northEast = map.unproject([798, 1], map.getMaxZoom());