I could able to remove the recent modified vertex of a feature using removePoint
method of modify interaction, as well as using deleteCondition
event of modify interaction. However, that is not what I am trying to achieve. The use case for this this problem is as below.
I have modify interaction added on map. Now when user tries to modify a feature over map, I am highlighting the vertices, like this
so that user can directly go to these vertices and then do right click
which will result in removal of vertex.
For this, I had to implement the contextmenu to handle the right click
over map. But, now the challenge is to remove the received coordinate from the modifying geometry.
I tried to implement it as follows, with simple .splice()
method on coordinate array of target geometry
if(this.modifyInteraction.features_.getLength() && this.modifyInteraction.features_.getArray()[0]){
//Feature being modified
let modifyft = this.modifyInteraction.features_.getArray()[0];
let coord = modifyft.getGeometry().getCoordinates()[0];
let foundIndex;
for(var k = 0; k < coord.length; k++){
if(coord[k][0] == rightClickedVertex.getGeometry().getCoordinates()[0] &&
coord[k][1] == rightClickedVertex.getGeometry().getCoordinates()[1]){
foundIndex = k;
break;
}
}
if(foundIndex && foundIndex > -1){
modifyft.getGeometry().getCoordinates()[0].splice(foundIndex, 1);
//nothing changes
}
}
is there any other way to remove the vertex of geometry being edited?