Igor-Vladyka / leaflet.motion

A simple tool to animate polylines and polygons in different way
https://igor-vladyka.github.io/leaflet.motion/
MIT License
207 stars 44 forks source link

Continue the line after drawing it #16

Closed Patabugen closed 2 years ago

Patabugen commented 3 years ago

I'm displaying routes that someone has traveled, your (superb) plugin lets me draw the line in a more natural way.

However I also want to display routes in real-time, which means loading the saved route and drawing it with leaflet.motion, but then adding to the length one or two waypoints at a time.

Do you have any suggestions for how I can add to an existing line (which may still be in motion, or may have finished?).

I've been experimenting with the addLatlng but don't think that's the right thing to do. I've also pondered using your Group feature and adding a new motionLine each time - but will be adding hundreds of mini lines that way and thought I'd see if there was a way to add one at a time?

Igor-Vladyka commented 3 years ago

Hello there.

I may need to think about it for a bit. It's not straight forward for now.

luquezsantiago86 commented 3 years ago

Hello, I have an interest in this.

Do you have any idea on how to do it?

For the moment what I am doing is to create an interval to read the last 2 coordinates os the polyline (the previous coordinate and the new added cordinate), and inside this interval I have the var lastLine = L.motion.polyline(...).

I works, but the problem is that the interval keeps drawing the same coordinates until I have a new coordinate.

ezgif com-gif-maker (1)

Also, I was looking to hide the marker and I couldnt, I thought it was the "showMarker" option that controls that feature.

Patabugen commented 3 years ago

I've not worked on this since, but hopefully will be in the next month or two so will let you know if I manage anything.

The objects are just JavaScript objects - could you add a property to them to record whether you've drawn the or not and skip the interval if so?

I'd be interested to see your code if it's somewhere you can share it.

Igor-Vladyka commented 3 years ago

Hello guys,

Have you tried to use Seq object? Create a seq with a initial line (when creating a line you surelly know start point and end point) And then just add to the seq new\next lines.

luquezsantiago86 commented 3 years ago

No, but it seems very usefull, it is a library? I will investigate about it. Thanks!

luquezsantiago86 commented 3 years ago

@Patabugen here is the section of my code where I tried to use motion with realtime feature, but I get a problem with the zoom.

https://github.com/luquezsantiago86/motion_rt/

Let me know if you if I can help you with something, and if you have any idea about this.

luquezsantiago86 commented 3 years ago

Hello guys,

Have you tried to use Seq object? Create a seq with a initial line (when creating a line you surelly know start point and end point) And then just add to the seq new\next lines.

Hi @Igor-Vladyka sorry to bother you. I came back to investigate this again. Do you have more information of what you said about "Seq objet"? I was look on the web but I am quite new in JS and couldnt find out what you tried to said.

Any information or example would be great, Thanks!

Igor-Vladyka commented 3 years ago

Hello.

What I mean is

L.motion.seq([], options).addTo(map);

it's a build in structure in current library to support sequential animation objects.

luquezsantiago86 commented 3 years ago

@Igor-Vladyka Thanks so much! I will give it a try!

Patabugen commented 2 years ago

Hey Both,

Thanks for the tip to look at seq @Igor-Vladyka ! I've had some success making addLayer work

Here's a pull request:

https://github.com/Igor-Vladyka/leaflet.motion/pull/25

@luquezsantiago86 not sure how familiar you are with package.json but if it saves you some time you can test out my version of the package just by changing your version string in package.json to mill-hill-automation/leaflet.motion#develop and running npm update.

Don't stay on my #develop branch for too long though, I may well break it :)

For example:

"dependencies": {
    "leaflet.motion": "mill-hill-automation/leaflet.motion#develop",
}
Igor-Vladyka commented 2 years ago

Hey guys, I'm back.

Let me check what the hell, fix will be released in next major version soon.

Patabugen commented 2 years ago

Welcome back @Igor-Vladyka! I'll have a look at your other comments when I'm working on that project work over the next few weeks, excited to have your input again :)

Igor-Vladyka commented 2 years ago

Hey guys. Currently it's implemented in latest version. Please check out documentation and example here, created by @Patabugen