mapbox / mapbox-gl-js

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
https://docs.mapbox.com/mapbox-gl-js/
Other
11.05k stars 2.21k forks source link

How to make a time series animation with Source and Layer #13044

Open ViniciusFariasS opened 7 months ago

ViniciusFariasS commented 7 months ago

How to make a time series animation with Source and Layer using the endpoint 'myendoint.com/weather/maps/${type}/${date}/tiles/{z}/{x}/{y}' where the date is dynamic to take 6 hours ahead of the current time, saving the previous images in cache so as to avoid unnecessary requests and the animation runs cleanly.

<Source id={'satellite'} type="raster" tiles={['myendoint.com/weather/maps/${type}/${date}/tiles/{z}/{x}/{y}']} tileSize={512} scheme='xyz' minzoom={5} maxzoom={12}> <Layer {...{ id: 'satellite-layer', type: 'raster', preload: 'infinity', source: 'satellite', paint: { 'raster-opacity': 0.8, 'raster-fade-duration': 650, } }} /> </Source >

GravacaodeTela2024-01-16as10 21 28-ezgif com-video-to-gif-converter

stepankuzmin commented 7 months ago

Hi @ViniciusFariasS,

You can try updating the source tiles URL with setTiles, however this might cause flickering https://docs.mapbox.com/mapbox-gl-js/api/sources/#rastertilesource#settiles

map.getSource('id').setTiles(['https://another_end_point.net/{z}/{x}/{y}.png']);