maplibre / maplibre-gl-js

MapLibre GL JS - Interactive vector tile maps in the browser
https://maplibre.org/maplibre-gl-js/docs/
Other
6.67k stars 716 forks source link

Keeping tiles after zooming out past `minzoom` #4800

Open bstadlbauer opened 1 month ago

bstadlbauer commented 1 month ago

User Story

As a user I can zoom out on a Raster Layer past minzoom and the tiles of the last available zoom (minzoom) are still present

Rationale

Hi everyone!

I'm currently working with a tile server which can only render up to a certain minzoom. I've set the minzoom in the <Source> accordingly. Now, similar to "overzooming", where tiles will stay past the maxzoom, it would be nice if they don't vanish when zooming out past minzoom.

I've looked around the API docs as well as other github issues, but couldn't figure out a way to achieve this, but I might have missed something.

Thank you for all the great work on the project!

bstadlbauer commented 1 month ago

In case there is a hacky way to do this I'd already be happy a well!

HarelM commented 1 month ago

You could probably hack it using addProtocol and returning an image made of higher zoom level tiles. But this might prove problematic (using both addProtocol or in general to implement this) when the minzoom and current zoom are a few levels of zoom apart...

ibesora commented 1 month ago

In case there is a hacky way to do this I'd already be happy as well!

How much "hacky" are you comfortable with? You can manually forge N tile requests, where N depends on the difference between your zoom level and the dataset zoom level, and inject the data in the SourceCache. After that, everything should work as expected

bstadlbauer commented 1 month ago

Thank you for the quick responses! My initial thinking went along the lines of re-using the tiles that have already been fetched for higher zooms, but I've got control over the cache headers, so that shouldn't be an issue either way.

I'll look into the options of injecting them into the SourceCache thank you!