-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pre-caching map tiles (raster) in memory - smooth weather animation #9841
Comments
You might want to take a look at https://github.com/AbelVM/mapworkbox |
@AbelVM thanks for the link - I like the approach but not really my case. I need to animate weather using different raster tile urls - in the current implementation there is no easy way to handle additional parameter besides |
There's where WorkBox shines as the easiest way to precache the tiles! The link I sent you is a PoC to check the performance impact in dynamic tiles precaching based on user interaction, but your use case is the simplest one: it only requires to precache the tiles' time-series at first and that's all. I'm using that approach at MAdB app, where a WorkBox starts precaching all the tiles (up to 80MB if you stay there enough) and some other heavy resources (up to 10MB), priority sorted, as the user opens the app, and then the pan and zoom is the smoothest it can be. You can even use it to proxy requests so Mapbox requests plain /z/x/y tiles (no changes in data source), while the cached ones have been requested to the server with the extra params. You can even manage the invalidation and refresh of the cache based on your own requirements. Then, once precaching is managed, you have two main options to animate the map, as described here, :
|
@AbelVM after couple iterations over the feature I found a compromise on how to have smooth transition between weather frames. The problem with preloading 45 frames of weather is that it piles up to ~1000 tile requests - even pre-caching is taking a lot so I needed to ditch that. Will have a fallback layer on lower zoom for single image source and starting from some zoom level like 6-7 the tiles layer takes on. On a side note: |
As an aside I've had a lot of success using feature states to animate vector timeseries. |
@kukiel - How are you handling forcing MapBox to reset the cache if the underlying source has been replaced? |
@klongmitre if you mean tile layer there is an internal api to do this, check this code https://github.com/mapbox/mapbox-gl-js/pull/8048/files
|
mapbox-gl-js version: 1.11.0
Question
Hi guys. My use-case is to display how the weather changes over the time and simulate it on the map. Something like this but the simulation will be much faster (lower interval between frames):
It requires to change tile source url - in addition to
x/y/z
there istimestamp
parameter for the weather.I tried something similar to the solution proposed here - #8048. The thing is that even when the tiles are cached in browser the whole process is not smooth enough - on a screen resolution 1920x958 I had 26 tiles for each frame and the browser is not coping with it smooth enough. Possible solution for that would be to pre-cache all the needed tiles into memory and eliminate requests. Is there any way mapbox supporting that - I would like to be able to provide all the tile urls that should be cached into memory.
Would appreciate any tips on how to solve that using mapbox - could also contribute when given some directions.
The text was updated successfully, but these errors were encountered: