How I can delete the polyline line between 2 specific marker. I have many polyline connected with many marker . But i want to delete any sspecific line on double click .
How Can I do that ?
I am using leaflet to draw the polyline.
here suppose I want to delete the polyline between marker 3 and 4 on double click. what will be procedure to do that.
Thank you.
I tried something like this but its not working , Can anybody please help me where is the mistakes ?
//polyline delete on double click
for (var i = 0; i < $scope.polycoords.length; i++) {
var polyline = $scope.polycoords[i];
$scope.polycoords[i].on('click', function (e) {
console.log("sdd",polyline._leaflet_id);
for (var j = 0; j < $scope.polycoords.length; j++) {
if($scope.polycoords[i]._leaflet_id = $scope.polycoords[j]._leaflet_id){
console.log($scope.polycoords[j])
var polyline = $scope.polycoords[j];
map.removeLayer(polyline);
}
}
});
}
polyline.on('dblclick', function (e) {
map.removeLayer(this);
});
Edit
This is going to work because based on your other question here on SO, I know that you create a different polyline for each line. But for anyone else that creates a single polyline with all the coordinates together, this solution will delete the whole polyline, not just a part of it.