nrenner / brouter-web

Web client for BRouter, a routing engine based on OpenStreetMap
https://brouter.de/brouter-web/
MIT License
363 stars 69 forks source link

Unify default max_zoom for custom layers and global maximum zoom #770

Closed rkflx closed 8 months ago

rkflx commented 1 year ago

Historically, many tile services have been providing tiles up to zoom level 18, with some later enabling zoom levels of 19 and beyond. BRouter-Web's current global limit is 19, which is used by some layers setting max_zoom in /layers/*.geojson. Tiles added via the custom layers dialog or configured in /config.js default to a maximum zoom of 18 due to this being a Leaflet default.

With a custom layer showing and zooming to 19, that layer will be disabled in the layers list. This has two effects:

When not disabling custom layers for zoom level 19, it would work like this:

Essentially there is a tradeoff between trying to avoid unsuccessful tile fetches and impacting the user experience. By making the tradeoff less conservative, tiles will be shown to users in more cases, at the expense of more 404 errors (but luckily no change in user experience) for servers not supporting level 19. Note that we already cause 404 errors for services not even supporting 18, as the limit of 18 is a best guess only anyway.

Given those considerations and the trend for more and more services to provide level 19 tiles, here we unify the global limit of 19 and the limit for custom layers (more precisely: any layer not having explicitly specified another max_zoom). This prioritizes user experience over overly cautious tile fetches.

This change can be considered a temporary measure. In the future, the global default in Leaflet could be increased, and in BRouter-Web custom zoom limits, auto-detection and up-scaling could be hooked up.

Fixes #726.

Test Plan:

rkflx commented 1 year ago

This seemingly simple topic can become quite mind-boggling:

If 404 errors for tile services not providing level 19 tiles are too controversial, we could additionally set maxNativeZoom=18. It would result in the following changes at zoom level 19:

IOW, this is another trade-off to decide on: Either we will never (this time for real) show gray tiles and always have blurry tiles at 19, or we will allow to show sharp tiles at 19 at the expense of sometimes displaying gray tiles.

I'll leave the PR as-is for now as I'd like to imagine most custom layers are actually supporting 19 and it is less confusing for users, but I'm open to be convinced otherwise. We could also differentiate, e.g. only (always) up-scale overlays and show sharp (sometimes gray) base layers. On the other hand, hiding an overlay is not as bad either. Also note that this won't help for the Strava heatmap, as it only supports 16 so the up-scaling would take effect too late. Opinions?

The ideal solution would of course be to make this configurable or auto-detect it, but that's out of scope for now.

rkflx commented 1 year ago

(Made this a bit more generic, no changes in behaviour.)

quaelnix commented 1 year ago

Opinions?

I think this pull request will satisfy the majority of users.

divulgacheur commented 10 months ago

I agree, this MR solve the issue effectively.