ewoken / Leaflet.MovingMarker

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

The moving marker is not always moving #24

Open goodwinfame opened 7 years ago

goodwinfame commented 7 years ago

Hi, I want to use this plugin to do some realtime play work. And I'm useing addLatLng to add a new point, it's about every 1 second I'll add a new point. But whatever I did, the markers mostly didn't move to the last new added point, however, by some unkown reasons it do move sometimes. Is there any way to fix this? here is my code, thanks very much. Btw, I'm using it in react.

const {user, map} = nextProps;
if (!user || !map) return;
const {coordinates, properties} = user;
if(!this.marker) {
  this.marker = L.Marker.movingMarker(new Array(coordinates,coordinates),1000,{autostart: true,icon: OnlineUser}).addTo(map.leafletElement);
} else {
  this.marker.addLatLng(coordinates,2000);

}
vidurgupta commented 6 years ago

@Goodwinfame were you able to solve this , I'm stuck on the same problem.

goodwinfame commented 6 years ago

@vidurgupta I fixed this long ago, I created this repo, hope its useful.

vidurgupta commented 6 years ago

@Goodwinfame Thanks, this will do.