Error Attempted to load an infinite number of tiles
node_modules/leaflet/dist/leaflet-src.js:11116:37 e._update
node_modules/leaflet/dist/leaflet-src.js:11082 e._onMoveEnd
node_modules/leaflet/dist/leaflet-src.js:593 e.fire
node_modules/leaflet/dist/leaflet-src.js:3303 e.panBy
node_modules/leaflet/dist/leaflet-src.js:4531 e._tryAnimatedPan
node_modules/leaflet/dist/leaflet-src.js:3181 e.setView
node_modules/leaflet/dist/leaflet-src.js:3293 e.panTo
node_modules/vue2-leaflet/dist/vue2-leaflet.min.js:1:25596 c.setCenter
node_modules/vue2-leaflet/dist/vue2-leaflet.min.js:1:1493 c.o.(anonymous function).custom.r.$watch.deep
node_modules/vue/dist/vue.common.js:3235 Xe.I3G/.Xe.run
Unclear how to reproduce this, I am getting bug tracking error logs from users.
Then we have no idea of what's going on.
Possibly related https://github.com/Leaflet/Leaflet/pull/5477, #5478 and https://github.com/Leaflet/Leaflet/issues/5479 - that very specific error message was added back then.
I came accross this issue while googling the exact same error message, I can give some insight into how to trigger it.
The map used to trigger it was straight-forward, just a simple map with a tile layer and markers. I got the error message when setting map.fitBounds(array) where array only contained one array element of coordinates For example:
This works:
map.fitBounds([
[40.712, -74.227],
[40.774, -74.125]
]);
This will cause Uncaught Error: Attempted to load an infinite number of tiles:
map.fitBounds([
[40.712, -74.227]
]);
The solution was to use map.setView instead of map.fitBounds if array contained only one item.
This will cause
Uncaught Error: Attempted to load an infinite number of tiles:map.fitBounds([ [40.712, -74.227] ]);
@hanneolsen No it won't. See https://plnkr.co/edit/jdnUKmxEtgERNMKYerbp?p=preview
@IvanSanchez You're right, projection config I used was needed to reproduce it. The plunkr below won't throw the error for some reason, but the same code running in Chrome (version 62) throws it.
https://next.plnkr.co/edit/XwZauqd9OECpkltt?preview
Hope the example makes sense. I'm new to leaflet and map coding in general.
I stumbled over this as well today and after some digging I found that this happens when you assign the zoom value to a string that looks like a float (in my case it was) "13.5" which was accidentally passed as a string.
Weird thing though is that THIS zoom (with the string) actually works well, but the next zoom (I am assuming calculating the next zoom level based on that string, 13.6 in my example) then lead to the error.
Agreed, this was my mistake, and I did not dig deeper than this so I am not entirely sure what leaflet does here, but maybe it could be enforced that no stupid people (like me) are just passing strings?
This usually happens when you setView the first time without defining zoom or defining zoom incorrectly
I came across the same issue. I get this error on this call:
this._map.flyTo(highlighted.searchResult.coordinates, { animate: true });
coordinates is of type L.LatLng.
I solved this problem on a .fitBounds(latlng) call by adding the maximal possible zoom to the options .fitBounds(latlng, {maxZoom: 28}). You can find the max zoom by counting the amount of zoom levels you provided when setting up the CRS for the map, e.g in my case:
crs = new Proj.CRS(
...,
{
resolutions: [4000, 3750, 3500, 3250, 3000, 2750, 2500, 2250, 2000, 1750, 1500, 1250,
1000, 750, 650, 500, 250, 100, 50, 20, 10, 5, 2.5, 2, 1.5, 1, 0.5, 0.25, 0.1]
...
})
Most helpful comment
This usually happens when you
setViewthe first time without definingzoomor definingzoomincorrectly