socib / Leaflet.TimeDimension

Add time dimension capabilities on a Leaflet map.
MIT License
433 stars 138 forks source link

Custom layer #194

Closed robochat closed 4 years ago

robochat commented 4 years ago

I'm writing a custom layer in order to have animated circles. I'm having trouble understanding how the TimeDimension.Layer class actually works. I thought that the mechanism was the following:

  1. _onNewTimeLoading(ev) runs to prepare for the next frame.
  2. At the end of _onNewTimeLoading(ev), it fires "timeload" and sets a variable like this._currentTime
  3. isReady(time) will test if time == this._currentTime
  4. _update() is triggered by the "timeload" event from _onNewTimeLoading() and changes the _currentLayer

But when I add logging to these functions. I don't see what I expect as the times out of step and the times from onNewTimeLoading get far in advance of the time shown on the time controller.

Should I instead be Using _onNewTimeLoading to create a cache of layers or parameters for all requested times. Using isReady(time) to test if the layer for that time exists. Using update to load from the cache the layer for the time retrieved from timeDimension.getCurrentTime()

But where and when should the timeload event be fired if there is no direct link between onNewTimeLoading and update

robochat commented 4 years ago

Ok. The correct mechanism is the second version. So I will close this issue now.