socib / Leaflet.TimeDimension

Add time dimension capabilities on a Leaflet map.
MIT License
435 stars 139 forks source link

How to use L.TimeDimension.prepareNextTimes(a, b, c) #180

Closed mo-ian-watkins closed 5 years ago

mo-ian-watkins commented 5 years ago

Could someone who understands how this works explain how exactly to use this please.

I basically want to animate through some WMS layers and would like to preload 4 frames ahead of the current frame shown so that they are cached once the animation gets to those frames.

Any help gratefully received.

bielfrontera commented 5 years ago

Hi @mo-ian-watkins, the easiest way would be to use the option minBufferReady (see L.TimeDimension.Player options and example 2).

If you set this option to 4, the player will call prepareNextTimes automatically.

mo-ian-watkins commented 5 years ago

Thank you.

We are not using the player as we will using our own time scrubber control.

But through trial and error, I got to the bottom of it, e.g.:

L.TimeDimension.prepareNextTimes(1, 4, true)

will load 4 frames ahead of current frame (plus wrap around if needed). If we call that as every frame is displayed, there will four frames preloaded or at least in the process of arriving.

I think the biggest confusion was what the first parameter actually did <Number> numSteps