Allows you to create new geometries, and change existing geometries, by interacting with a MapView. To use a GeometryEditor:
Set the MapView.geometryEditor property.
Call one of the start methods.
You can then edit the geometry directly on the map view using mouse or touch gestures.
If you passed in an initial geometry, it is displayed in the view, and you can interact with the geometry to make changes.
Call GeometryEditor.stop() to return the geometry and prevent the geometry editor from processing any more interactions.
When started (GeometryEditor.isStarted is true), you can interact with the different GeometryEditorElement objects that compose the representation of the GeometryEditor.geometry in the map view. Depending on what is selected, different types of GeometryEditorElement are returned from GeometryEditor.selectedElement. Tap to select the different elements and drag to move them. Tap multiple times on an element to select the different types of GeometryEditorElement representing vertices, parts, and the entire geometry. You can control which interactions are possible by changing the InteractionConfiguration of the current GeometryEditor.tool. For example, you can change the types of element you can tap to select, and whether they can create new vertices or parts by tapping or dragging on the map. Programmatic changes to the GeometryEditor.geometry or GeometryEditor.selectedElement (for example GeometryEditor.selectVertex(Int, Int) or GeometryEditor.moveSelectedElement(Point)) are not affected by the settings in InteractionConfiguration. The type of the current GeometryEditor.tool determines what type of interactions will add new vertices and parts to the geometry.
Programmatic editing methods are also provided so you can augment your interactive geometry editing to support specific user requirements. For example:
Use GeometryEditor.insertVertex(Point) to add a subsequent vertex based on a GPS location from LocationDisplay.
Use GeometryEditor.moveSelectedElement(Point) to move the currently selected GeometryEditorElement to a specific Point, or GeometryEditor.moveSelectedElement(Double, Double) to nudge it in a specific direction.
Use GeometryEditor.replaceGeometry(Geometry) to take the current GeometryEditor.geometry, apply an operation such as a union or intersect by using GeometryEngine, and then replace the current geometry with the result so you can continue to edit as required.
Use GeometryEditor.geometryChanged and GeometryEditor.selectedElementChanged to be notified when a user interaction or API call has changed the GeometryEditor.selectedElement or GeometryEditor.geometry. Changing the geometry state can also change GeometryEditor.canUndo, which triggers GeometryEditor.canUndoChanged.
The element that is currently selected in the GeometryEditor, or null if nothing is selected. Clicking or tapping on the different visible elements of a GeometryEditor.geometry in a view allows you to select and unselect them. This property returns a different type of GeometryEditorElement depending on what is selected - a vertex (GeometryEditorVertex), a mid-vertex (GeometryEditorMidVertex), a part of a polygon or polyline (GeometryEditorPart), or the entire geometry (GeometryEditorGeometry). You can change which selection interactions are allowed by using the InteractionConfiguration of the GeometryEditor.tool.
Creates a new vertex at the specified location and inserts it after the currently selected element, or appends the point if there is nothing selected. If GeometryEditor.geometry is empty (Geometry.isEmpty is true), the given point is added as the initial vertex, and then selected. If nothing is selected (GeometryEditor.selectedElement is null), the point is appended to the end of the GeometryEditor.geometry, and then selected. If GeometryEditor.selectedElement is the first vertex in a part of a Multipart, the given point is inserted before the currently selected vertex, and then selected.
Moves the selected element to the specified location. If GeometryEditor.selectedElement is a GeometryEditorVertex, then the location of the vertex is moved to the given point. If the GeometryEditor.selectedElement is any other type of GeometryEditorElement, then the center of the element is moved to the given point.
Moves the selected element by the specified distances along the x-axis and y-axis.
Replaces the current GeometryEditor.geometry with the specified geometry. Use this method to make changes to the GeometryEditor.geometry that are not directly supported using other GeometryEditor methods. For example, to start a new part in a Polygon or Polyline geometry, get the current GeometryEditor.geometry, use a MultipartBuilder to add the required part, and then pass the updated GeometryBuilder.toGeometry() to this method.
Rotates the GeometryEditor.selectedElement by the specified angle. The angle of rotation is used in the form of the modulo of 360 degrees; for example rotating by 540 degrees is equivalent to rotating the by 180 degrees. A positive value corresponds to a counterclockwise rotation.
Scales the selected element by the specified factors. If the origin Point has a different SpatialReference than the associated MapView, the point will be reprojected before the geometry is rotated, using the default transformation.
Selects the entire GeometryEditor.geometry. When the entire geometry is selected it can be edited interactively and programmatically. For example you can move the entire geometry interactively by dragging, or call GeometryEditor.moveSelectedElement(Point) or GeometryEditor.moveSelectedElement(Double, Double) to move it programmatically.
Selects the mid-vertex with the specified indices. Mid-vertices do not exist in the GeometryEditor.geometry. They exist only in the display to serve as a visual cue that new vertices can be inserted between existing vertices. Since they do not exist in the geometry, mid-vertices cannot be programmatically moved or deleted. They can be used to insert a new vertex interactively.
Selects the part with the specified index. When a part of a polygon or polyline geometry is selected, a GeometryEditorPart is returned from GeometryEditor.selectedElement. If the polygon or polyline has only one part[Part], then a GeometryEditorGeometry with a shape equivalent to the entire geometry is returned from GeometryEditor.selectedElement instead, which provides immediate access to the extent (Geometry.extent) and can be directly used in other geometry operations. If the current GeometryEditor.geometry is a Point or Multipoint, the entire geometry is selected.
Selects the vertex with the specified indices. When a vertex is selected it can be edited while all other vertices of the geometry are unchanged. For example, you can move only the selected vertex interactively by dragging, or call GeometryEditor.moveSelectedElement(Point) or GeometryEditor.moveSelectedElement(Double, Double) to move the selected vertex programmatically.
Starts a geometry editing session based on the specified geometry. Use this method for data editing workflows, where you have an existing Geometry to be updated. After calling this method, the geometry is drawn in the map view, and interactions with the map view will select and edit the geometry, depending on the current GeometryEditor.tool and its InteractionConfiguration.
Starts a geometry editing session with an empty geometry of the specified GeometryType. Use this method for data creation workflows, where you know the GeometryType required but do not have an existing geometry to edit. After calling this method, nothing is drawn on the map view initially - user interactions on the map view will define and edit the geometry, depending on the current GeometryEditor.tool.