Leaflet: Error Attempted to load an infinite number of tiles

  • I’m reporting a bug, not asking for help; support questions like “How can I do X with Leaflet?” will be closed (use Stack Overflow or gis.stackexchange.com for questions)
  • I’ve looked at the documentation to make sure the behaviour is documented and expected
  • I’m sure this is a Leaflet code issue, not an issue with my own code nor with the framework I’m using (Cordova, Ionic, Angular, React…)
  • I’ve searched through the issues to make sure it’s not yet reported

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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

This usually happens when you setView the first time without defining zoom or defining zoom incorrectly

I’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 of proj4leaflet-crs to get the scale of a zoom level for a resolution which is not available. So you need to set the maxZoom of the map to the amount of resolutions - 1 (because of starting with 0).

var map = L.map('map', {
	crs: crs(),
	center: [0, 0],
	zoom: 0,
	maxZoom: resolutions.length - 1 // <--------------- This line
});

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.