public final class GeometryEditor extends Object
Allows you to create new geometries, and change existing geometries, by interacting with a MapView.

To use a GeometryEditor:

  • Set the MapView.geometryEditorProperty().
  • Call one of the start methods.
  • You can then edit the geometry directly on the map view using mouse or touch gestures.
    • The toolProperty() determines how you draw on the map to define the new geometry, for example by adding individual vertices or with a freehand gesture. The default tool is VertexTool.
    • If you passed in an initial geometry, it is displayed in the view, and you can interact with the geometry to make changes.
  • Call stop() to return the geometry and prevent the geometry editor from processing any more interactions.
    • Geometries are immutable, therefore a new Geometry object reflecting the updates is returned from geometryProperty() and GeometryEditor.stop() each time.

When started (startedProperty() is true), you can interact with the different GeometryEditorElement objects that compose the representation of the geometry in the map view. Depending on what is selected, different types of GeometryEditorElement are returned from the selectedElementProperty(). 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 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 geometryProperty() or selectedElementProperty() (for example selectVertex(long, long) or moveSelectedElement(Point)) are not affected by the settings in InteractionConfiguration. The type of the current GeometryEditor.toolProperty() determines what type of interactions will add new vertices and parts to the geometry.

Change the appearance of the geometry by using the GeometryEditorStyle of the current GeometryEditor.toolProperty() tool - for example to match the symbology used by the graphic or feature being edited.

Programmatic editing methods are also provided so you can augment your interactive geometry editing to support specific user requirements. For example:

Use change listeners on geometryProperty() and selectedElementProperty() to be notified when a user interaction or API call has changed the GeometryEditor.selectedElementProperty() or GeometryEditor.geometryProperty().

Changing the geometry state can also change canUndoProperty().