ewoken / Leaflet.MovingMarker

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

How to use the events (start, end, loop)? #25

Closed gcivicodev closed 6 years ago

gcivicodev commented 7 years ago

Hi @ewoken

I am using your plugin in ionic v1 project. How can I use the events (start, end, loop)? I am using this code:

leafletData.getMap('app-map').then(
    function(map) {
        // more code here ...
        var trolleyIcon = L.icon({iconUrl: 'http://www.freeiconspng.com/uploads/bus-icon-10.png',iconSize:[64,64]});
        trolley = L.Marker.movingMarker(routeTest,[2000],{type:'trolley',icon:trolleyIcon}).bindPopup(
            'This is the Trolley!'
        ).addTo(map);
        trolley.start();
        trolley.on('start',function(e) {
            console.log('start event',e);
        });
        trolley.on('end',function(e) {
            console.log('end event',e);
        });
    }
);

I tried:

trolley.on('end',function(e) {
        console.log(e);
});

But nothing happen.