visgl / deck.gl

WebGL2 powered visualization framework
https://deck.gl
MIT License
12.24k stars 2.08k forks source link

How can I keep cached tiles of TileLayer visible when zoom < minZoom? #4448

Closed MehdiSaffar closed 4 years ago

MehdiSaffar commented 4 years ago

I have a TileLayer that fetches nodes from my server. I set minZoom equal to maxZoom otherwise I would be fetching the same nodes but multiple times. It behaves as I want it when my current zoom is >= maxZoom by keeping the tiles in view, but when zoom < minZoom they disappear abruptly.

Now I know that TileLayer is supposed to be used when you have cached tiles of some location with different resolutions etc.. but is there any way to keep the cached tiles visible even when zoom < minZoom? I tried zoom = 0 and zoom = null, but then it would try to fetch bigger and bigger areas.

Here is a GIF of the behavior I have right now:

ezgif com-optimize

Relevant part of the code:

   minZoom: zoomValue,
   maxZoom: zoomValue
   ...otherProps
})
kylebarron commented 4 years ago

I think that's generally not possible. Overzooming on the fly is easier because you don't have to perform any aggregation on the fly. Other map rendering engines like Mapbox GL similarly support overzooming but not underzooming.

In my experience I've created aggregation tiles ahead of time to serve at lower zooms

Edit: I take that back... I'm not sure how difficult it would be to support underzooming.

MehdiSaffar commented 4 years ago

@kylebarron I also dont think it wouldnt be hard to support underzooming. The behavior I want is simply this:

viewport.zoom < minZoom ? draw the tiles we have, dont try to fetch anything
viewport.zoom between minZoom and maxZoom ? fetch as usual
viewport.zoom > maxZoom ? fetch tile at size of maxZoom

if such thing cannot be implemented, I guess I'll have to dig into TileLayer and Tileset2D myself.

kylebarron commented 4 years ago

I think that's not a common use case, which is why it's not implemented... That means that if you zoom to minzoom-ε and pan, you'll never load new data. That said I don't think it would be too hard to modify TileLayer to support it

MehdiSaffar commented 4 years ago

It is not a common case you are right. I'll try myself and see what I can come up with. Thank you

ilan-gold commented 4 years ago

I have posted something similar, I believe at #4373. I proposed a "fix" to the codebase, but it is far from perfect (you'll see the back and forth we had about what I proposed - it doesn't work for zooming that is too quick). I got around this by maintaining a "background image" but I have >0 zoom levels in my use case so generating that static image was simple on the fly.