Once you've added one or more polylines with clickable actions on your map, and want to use the measure tool PolylineMeasure, those polylines will exist in some way. How can I get all created polylines in a map to disable clickability, just like you can with polylines directly you can click with marker on the map.
L.polyline(latlngs, {clickable: false}).addTo(map);
Polyline disable in Leaflet
You need to traverse all layers, you can use the
eachLayer function
to achieve this. And remove theclick event listener
. Just use the.off function
like this:layer.off('click');
In my code below it will remove the line from eachpolyline
Removeevent listener
.The following is the code: