Add/delete vertex when editing a geometry

08-04-2017 10:23 AM
New Contributor II

Hopefully this is an easy question to answer.

After putting a polygon into edit mode, what is the action (mouse and/or key strokes) to add a vertex and delete a vertex?

I get how to move a vertex and move/scale/rotate the polygon, but adding/deleting a vertex is being elusive.

mapView.Editor.EditorConfiguration.AllowAddVertex = true;

mapView.Editor.EditorConfiguration.AllowDeleteVertex = true;

return await mapView.Editor.EditGeometryAsync(geometry);

Using ArcGIS Runtime Desktop API for Microsoft .Net  version

3 Replies
Esri Regular Contributor

AddVertex and DeleteVertex commands can be activated using buttons just like Undo/Redo/Cancel/Complete commands. They are only enabled for Polyline/Polygon geometries though with provided CommandParameter. DeleteVertex will act on selected vertex (red highlight) and/or given index. 

            <Button Content="Undo"
                    Command="{Binding ElementName=MyMapView, Path=Editor.Undo}" />
            <Button Content="Redo"
                    Command="{Binding ElementName=MyMapView, Path=Editor.Redo}" />
            <Button Content="Delete"
                    Command="{Binding ElementName=MyMapView, Path=Editor.DeleteVertex}" />
            <Button Content="Add"
                    Command="{Binding ElementName=MyMapView, Path=Editor.AddVertex}" />
            <Button Content="Cancel"
                    Command="{Binding ElementName=MyMapView, Path=Editor.Cancel}" />
            <Button Content="Complete"
                    Command="{Binding ElementName=MyMapView, Path=Editor.Complete}" />‍‍‍‍‍‍‍‍‍‍‍‍

Programmatically, you can invoke them using the following code:

            // `mapPoint` will be added after selected vertex
            if (MyMapView.Editor.AddVertex.CanExecute(mapPoint))
            // `index` to delete specific vertex or
            // `null` to delete selected vertex
            if (MyMapView.Editor.DeleteVertex.CanExecute(index))

You may also use Polyline/PolygonBuilder which also has methods for Add/RemovePoint.

0 Kudos
New Contributor II

Thanks for your response, Jennifer.  I understand your example, but that's not what I'm looking for.

Refer to the image I attached in my question.  I want to deal with that edit object directly on the map.  I figured out that the white circles in between the vertices are how you add a vertex.  Click on one, drag it around, and release and you are rewarded with a new vertex and extra white circles to drag around.  By setting AllowAddVertex = false, the white circles go away.

mapView.Editor.EditorConfiguration.AllowAddVertex = false;

return await mapView.Editor.EditGeometryAsync(geometry);

When AllowDeleteVertex = true, what do I do with the edit object on the map to delete a vertex?

New Contributor II


0 Kudos