allartk / leaflet.offline

Leaflet offline layer
https://allartk.github.io/leaflet.offline/
GNU Lesser General Public License v3.0
305 stars 76 forks source link

Fix/handle-out-of-bounds-tiles #352

Closed cr3a7ure closed 2 months ago

cr3a7ure commented 7 months ago

This is a common scenario when retrieving tiles beyond zoom level 19 on openstreetmaps and from other servers too. I followed the least changes approach. The saved blob, does not get rendered from leaflet. We can also return a null sized image blob.

Thanks for the time to review it.

allartk commented 7 months ago

Hi, thanks for the pull request!

I wonder, can you prevent those download attempts be configuring bounds and zooms of the layer?

cr3a7ure commented 7 months ago

I have not studied your code in more depth TBH, but I believe it will require more logic for sure. Especially if you had in mind the base layer which covers most of the times the whole map. I am serving custom geoTIFF overlays as WMTS layers which means that they are oddly shaped. I cannot suggest a universal way to retrieve bounds/zoom/layer.

On my scenario, I retrieve the bounds of the layer via WMS Info calls on GeoServer, I set those in the extent of the leaflet map and then proceed to use saveTiles on those bounds.

For compatibility reasons and stability we could use a flag in options to allow those 400s be counted towards saveend event. I have deployed the change and monitoring the user experience.

Thanks for jumping in.