AnsweredAssumed Answered

How do I delete a vertex from an existing polyline?

Question asked by tomrip on Oct 9, 2015
Latest reply on Oct 13, 2015 by tomrip

Hello,

 

I am trying to delete a vertex from an existing polyline, and I cannot seem to figure out the workflow to do it.  From a UX perspective, my idealized version of the workflow would be to start an edit operation on a polyline, select a particular vertex, right click to open a context menu, and then click a 'Delete' button.  That part of the workflow I can do, but I can't figure out what to do in the code after the 'Delete' button has been clicked.

 

How do I get access to selected vertex?

  • There is a private property (m_VertexPosition) on the MapView.Editor object that I would like to access but can't get to directly. Ideally, that should be a public property that I could get to.
  • There is a VertexPosition property in the GeometryEditStatus event object that is passed into the 'Progess.ProgressChanged' event, but that event seems to be raised only after some edit action, e.g. move, etc, has been performed. And I am not sure how to manually raise the event with a fully populated GeometryEditStatus
  • I though about using a 'mousedown' event when the vertex is selected, and iterating over the Editor's input geometry to find a matching coordinate pair, but what happens if the user wants to delete a vertex that was added as part of the edit action and is not part of the input geometry

 

So it seems like i am not on quite on the right path for now.  Any help or guidance would be greatly appreciated.

 

Thank you.

 

Sample Code

Progress<GeometryEditStatus> progress = new Progress<GeometryEditStatus>();
progress.ProgressChanged += progress_ProgressChanged;
Geometry.Geometry newPolyline = await mv.Editor.EditGeometryAsync(g.Geometry, null, progress); 
progress.ProgressChanged -= progress_ProgressChanged;


void progress_ProgressChanged(object sender, GeometryEditStatus e)
{
       if (e.GeometryEditAction == GeometryEditAction.MovedVertex)
       {
              ICommand delete = mv.Editor.DeleteVertex;
              delete.Execute(e.VertexPosition);
       }
}

Outcomes