ewoken / Leaflet.MovingMarker

A Leaflet plug-in to create moving marker
MIT License
342 stars 177 forks source link

addStation not working correctly #9

Closed alexookah closed 8 years ago

alexookah commented 8 years ago

When addingstation with PointIndex from a polyline.... the number is not correct used in addStation(pointIndex,duration)

let's say i have this polyline: [[40.64397,22.908537],[40.643888,22.908784],[40.643672,22.90953],[40.64353,22.909975],[40.643404,22.910372],[40.643294,22.910758],[40.643041,22.911461],[40.642752,22.912373],[40.642447,22.913349],[40.642077,22.91446],[40.641413,22.916622],[40.641002,22.917925],[40.640884,22.918279],[40.640807,22.918569],[40.640611,22.919433],[40.640599,22.919486]]

i want to addStation on points: 1,4,7,10,11,13,14

but for some reason i had to use 1,5,9,13,15,18,20 to make it work.

after the first addStation i had to add +1, +2, +3, +4 , +5, +6

ewoken commented 8 years ago

Because the current implementation of addStation adds a new point in the polyline with the given duration. I will try to fix it asap.

alexookah commented 8 years ago

nice of you to fix this. I tried to create some Go to Next station and Go to Previous station.... which i finally did it manually by reseting the durations the current marker had.... (was a pain in the ***) hopefully if you could add such a functionality it would be great :)

alexookah commented 8 years ago

You could also include a fixed speed for the polyline's.... this is how i did duration for each point so that the speed on each spot is the same... check it out.

var speedArray = [] var speed; var distance; var speedToRUN = 20 var interval = 10000

for (var i = 1; i < diadromi1.length; i++) { distance = L.GeometryUtil.distance(map,diadromi1[i-1], diadromi1[i]) speed = distance * interval / speedToRUN speedArray.push(speed) } i am not sure if the calculations are correct but i managed to have same speed on each polyline...