socib / Leaflet.TimeDimension

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

Can't find a way to open popups by default and keep them open while playing #197

Closed waldner closed 3 years ago

waldner commented 4 years ago

I'm using GeoJSON with addLastPoint: true which creates a marker on the last point. I'd like to bind a popup to this marker (done in pointToLayer), immediately open the popup (not been able to do), and, more importantly, keep the popup open even during playback (ie, after clicking "play" on the player control). Is this possible at all? Would you accept it as feature request?

EDIT: Reading through the bugs, I found the timeloading event mentioned. Listening on that event and (re)opening the popup at each invocation produces flickering and is not a viable solution.

r1m commented 3 years ago

The way I would solve it : create your own popup using L.popup and move/update it on timeloading.

waldner commented 3 years ago

The way I would solve it : create your own popup using L.popup and move/update it on timeloading.

Unfortunately, for moderate to high frame rate that is virtually unusable due to flickering. Furthermore, I'd like the popup to stay open even when the user pauses the playback.

r1m commented 3 years ago

I did not test but i'm guessing that if you add your own popup without binding it to a marker. You can then move it opened.

var popup = L.popup()
    .setLatLng(lastpointCoordinates)
    .setContent('<p>Hello world!<br />This is a nice popup.</p>')
    .openOn(map);

On timedimension changes, find the last point and update the position using popup.setLatLng. I'm sorry if it's already what you've done. I will have to test this.

waldner commented 3 years ago

Ah, that's a nice idea. I'll check it tomorrow and let you know. Thanks!

waldner commented 3 years ago

if you add your own popup without binding it to a marker. You can then move it opened.

This needed a few adjustments but set me on the right track. It works very well. Thanks!