P粉1387117942023-08-19 09:54:58
You need to traverse all layers, you can use the eachLayer function
to achieve this. And remove the click event listener
. Just use the .off function
like this: layer.off('click');
In my code below it will remove the line from each polyline
Remove event listener
.
The following is the code:
// 我假设'map'是您的L.Map实例。 map.eachLayer(function(layer) { if (layer instanceof L.Polyline) { // 从该折线中移除点击事件监听器。 layer.off('click'); } });