I hope anyone out there would be able to assist me in this...
During editing a line shape using the EditOverlay, how do I get to find out the index of newly added vertex, moved vertex, and deleted vertex?
Appreciate your advise...
I hope anyone out there would be able to assist me in this...
During editing a line shape using the EditOverlay, how do I get to find out the index of newly added vertex, moved vertex, and deleted vertex?
Appreciate your advise...
Mostafa,
Thanks for your post and question.
Try the following events, hope it helps:
winformsMap1.EditOverlay.VertexAdded += new EventHandler<VertexAddedEditInteractiveOverlayEventArgs>(EditOverlay_VertexAdded);
winformsMap1.EditOverlay.VertexMoved += new EventHandler<VertexMovedEditInteractiveOverlayEventArgs>(EditOverlay_VertexMoved);
winformsMap1.EditOverlay.VertexRemoved += new EventHandler<VertexRemovedEditInteractiveOverlayEventArgs>(EditOverlay_VertexRemoved);
void EditOverlay_VertexRemoved(object sender, VertexRemovedEditInteractiveOverlayEventArgs e)
{
Vertex vertex = e.RemovedVertex;
}
void EditOverlay_VertexMoved(object sender, VertexMovedEditInteractiveOverlayEventArgs e)
{
Vertex vertex = e.MovedVertex;
}
void EditOverlay_VertexAdded(object sender, VertexAddedEditInteractiveOverlayEventArgs e)
{
Vertex vertex = e.AddedVertex;
}
Any more questions please feel free to let me know.
Thanks.
Yale
Thanks Yale for your response..
I did tried the above events. However, what I would like to get is to identify the index of the vertex, i.e. lets say I have a line shape of 5 vertices, and I moved using the map vertex number 3, what i want to get is within the event I need to identify which vertex that was moved in the line shape (number 1,2,3,4, or 5)
I also tried to loop through the EditShapeLayer and ExsitingPointsLayer and compare the "e.AddedVertex" but these two layers doesnt seem to hold the new vertex...
Hope this makes sense.... And waiting for your feedback
Mostafa,
It’s possible to pass out the index of the vertex at event arguments if modify the source code, however we need to consider how to make the API good for all users, for example, the edit shape is a MultiPolygonShape with multi polygons and each polygon has outer ring and many inner ring, one integer value can not represent the index of vertex.
In your scenario you can loop through the EditShapeLayer to find the target line, and then loop through the vertices of the line to find the index of adding vertex. You can refer to sample code below.
RectangleShape searchingArea = new RectangleShape(targetPointShape.X - searchingTolerance, targetPointShape.Y + searchingTolerance, targetPointShape.X + searchingTolerance, targetPointShape.Y - searchingTolerance);
for (int i = 0; i < targetLineShape.Vertices.Count - 1; i++)
{
LineShape currentLine = new LineShape(new Vertex[] { targetLineShape.Vertices[i], targetLineShape.Vertices[i + 1] });
if (searchingArea.Intersects(currentLine))
{
int indexOfVertex = i + 1;
break;
}
}
Thanks,
James