1
I have a map with several animated markers and I would like each of them to be removed individually at the end of the respective movement. I’m using the Leaflet library as well as Leaflet.MovingMarker. I’ve tried the methods isEnded
and end
without any success.
With the latter, the following code removes only one of the markers. Full code here
marker.on('end', function() {
map.removeLayer(this);
});
An event click
in place of end
works perfectly, every and every marker is removable, but that’s not what I’m looking for:
marker.on('click', function() {
map.removeLayer(this);
});
I haven’t had any luck with the method either isEnded
:
var ended = marker.isEnded();
if (ended = true) {
console.log("this marker ended!");
map.removeLayer(this);
}
Someone has since suggested to me that the problem may be related to closures within ties (see MDN document on the subject here). I’m also convinced that’s the problem, but no matter how hard I try I can’t find a solution.
What am I missing? Thank you in advance.