Leaflet: Leaflet tries to get negative value images or images that don't exist
Here is my Leaflet config:
function init() {
var mapMinZoom = 2;
var mapMaxZoom = 5;
var map = L.map('map', {
maxZoom: mapMaxZoom,
minZoom: mapMinZoom,
crs: L.CRS.Simple
}).setView([0, 0], mapMaxZoom);
var mapBounds = new L.LatLngBounds(
map.unproject([0, 4352], mapMaxZoom),
map.unproject([2048, 0], mapMaxZoom));
map.fitBounds(mapBounds);
L.tileLayer('/assets/themes/sec/img/tiles/{z}/{x}/{y}.png', {
minZoom: mapMinZoom,
maxZoom: mapMaxZoom,
bounds: mapBounds,
noWrap: true,
continuousWorld: true
}).addTo(map);
var store_marker = L.marker([0, 0]).addTo(map);
}
Everything works, but I get a lot of “resource not found” in my console whenever I zoom or pan:
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (0.png, line 0)
http://localhost:3000/assets/themes/sec/img/tiles/2/-1/0.png
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (0.png, line 0)
http://localhost:3000/assets/themes/sec/img/tiles/2/1/0.png
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (1.png, line 0)
http://localhost:3000/assets/themes/sec/img/tiles/2/-1/1.png
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (1.png, line 0)
http://localhost:3000/assets/themes/sec/img/tiles/2/1/1.png
I have no negative numbered tiles. The files referenced here don’t exist. Yet everything looks fine on the map. I used MapTiler to build the map. Anything I can do to fix this?
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 22 (10 by maintainers)
@josephrocca If you specify the
noWrap
option, and not thebounds
option for the tilelayer, then this is behaviour as expected.i downloaded the latest: Leaflet 1.0.3 and i still see this 404 when i zoom out of map with noWrap because of 0 and negative numbers in the x y z. anyone knows how to solve this?