perliedman / leaflet-routing-machine

Control for routing in Leaflet
https://www.liedman.net/leaflet-routing-machine/
Other
1.06k stars 347 forks source link

linetouched event doesn't triggered if addwaypoints = false #683

Closed Basile001 closed 1 year ago

Basile001 commented 1 year ago

Hi there,

If my line has addWaypoints set to false the linetouched event doesn't triggered. I want to do something other than add waypoints to my route.

            waypoints: waypoints,
            .......
            routeLine: (route) => {
                var line = L.Routing.line(route, {
                    styles: [{ color: "red", weight: 4 }],
                    extendToWaypoints: true,
                    missingRouteTolerance: 0,
                    addWaypoints: false
                });
                line.on('linetouched', (e: L.LeafletEvent) => {
                    console.log(e);
                });
                return line;
            },

Kind regards, Basile

Basile001 commented 1 year ago

Sorry I found a solution in an old post :

                line.eachLayer((l) => {
                    l.on('click', (e) => {
                        console.log(e);
                    });
                });