1

I'm using Leaflet, and using OSM's tile.openstreetmap.org tile server. However, sometimes my application does not load the maps tiles. It seems OSM's servers are having some problems sporadically, which is out of my scope of fixing. So, my question:

Is it possible to wait an X amount of time for the tile server to load the requested tiles, before trying to contact another URL for its tiles?

1

I don't think Leaflet supports this out of the box. However, I think you can implement such a behavior using events such as tileloadstart and tileload: http://leafletjs.com/reference.html#tilelayer-tileloadstart

For example, you could start counting time the first time a tileloadstart is fired using setTimeout, and cancel it (using clearTimeout) once a tileload is fired. If nobody cancels the setTimeout, swap the base OSM layer for another one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.