line_animator icon indicating copy to clipboard operation
line_animator copied to clipboard

can i update the line in Real time by adding more latlng

Open thorizer opened this issue 3 years ago • 7 comments

is updating the line in Real time by adding more latlng possible ?

thorizer avatar Aug 14 '22 09:08 thorizer

I think so (if I understand correct), as it's doing that all the time anyway. Just remember to call setState on the whole thing to update.

ibrierley avatar Aug 14 '22 09:08 ibrierley

will that animate the line from the start ou just then new update?

thorizer avatar Aug 14 '22 09:08 thorizer

ah maybe I'm misunderstanding then...it will probably depend on your settings, if its mid-animation and you add some points, I'm not quite sure what will happen. Try it :).

ibrierley avatar Aug 14 '22 10:08 ibrierley

will try and see how it works

thorizer avatar Aug 14 '22 10:08 thorizer

I have a feeling it will probably just animate the original line (it kind of uses originalPoints to then build an interpolated state builtPoints, which probably won't be updated), as it duration won't really make sense, when bits get added on. So I think it would only work "properly" on a fresh set of data each time. Apologies if I confused you with that earlier as I misunderstood what you were after...

It sounds a bit like you want some slightly delayed animation based on real time information ? Just trying to think if there's a way around that, ie build the main line each time (non-animated as the time has passed), and just use the LineAnimator for each new delayed point, but it depends on the exact use case really.

ibrierley avatar Aug 14 '22 10:08 ibrierley

Just to explain a bit clearer... Have 2 Polylines

PolyLineLayerOptions( polylines: [
   alreadyCompletePolyline,  
   animatingPolyline //(which is the one LineAnimator updates)
])

As you get a new point, you create a new LineAnimator from the last point of alreadyCompletePolyline, to the new point, for a duration of 5 seconds for example. Once that animation is complete, add that last point to the alreadyCompletePolyline, and then create a new animatingPolyline from that point to the new one again. And so on...

ibrierley avatar Aug 14 '22 10:08 ibrierley

@ibrierley thanks, I'm currently using flutter_map v3, i'll try it when this plugin gets updated

thorizer avatar Aug 21 '22 01:08 thorizer