How to reproduce
- Leaflet version I’m using:
- Browser (with version) I’m using: Chrome 70.0.3538
- OS/Platform (with version) I’m using: Windows 10
- Unclear how to reproduce this, I am getting bug tracking error logs from users.
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
This usually happens when you
setView
the first time without definingzoom
or definingzoom
incorrectlyI’m probably working on a problem similar to @hanneolsen with a custom map and projection.
The solution we ended up with was to specify min and max zoom levels when initiating the Leaflet map. I think this approach is beneficial as it should cover other situations other than the fitbounds case.
L.map("map", { crs: projection, minZoom: 3, maxZoom: 16 })
Yes I got this when I upgraded leaflet to 1.9.2 and vue-leaflet 0.6.1. Thank you dagfs for the solution.
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?
After I digged into this error, it is a pretty clear case. This happens only for custom projected maps. Also it makes no difference which Leaflet version. I tested it down until
1.6.0
- always the same error.Leaflet tries to get the scale of the zoom, for this it calls the
scale
function ofproj4leaflet-crs
to get the scale of a zoom level for a resolution which is not available. So you need to set themaxZoom
of the map to the amount ofresolutions - 1
(because of starting with 0).Error: https://plnkr.co/edit/5WaYrCWyEtDEoASH Fixed: https://plnkr.co/edit/otztxuMrUjSGixdm
This needs to be fixed in https://github.com/kartena/Proj4Leaflet! Leafet core is the wrong place to fix this.
We are using @vue-leaflet/vue-leaflet 0.6.1 to interface with leaflet using Vue components. This broke for us between leaflet 1.8 and 1.9. You might consider @vue-leaflet/vue-leaflet to be a reproduction. If this case will be helpful in addressing this issue, then I can get a little more specific.
We should check this again.