GeometryEditor QML Type

MapView."> GeometryEditor QML Type | ArcGISQtQml
  • Esri.ArcGISRuntime
  • GeometryEditor
  • Allows you to create new geometries, and change existing geometries, by interacting with a MapView. More...

    Import Statement: import Esri.ArcGISRuntime
    Since: Esri.ArcGISRuntime 200.1
    Inherits:

    Object

    Properties

    Signals

    Methods

    Detailed Description

    To use a GeometryEditor:

    • Set the MapView::geometryEditor property.
    • Call one of the start methods.
    • To interactively create new geometries from scratch, call startWithGeometry(Enums.GeometryType) passing in a Enums.GeometryType to determine the type of geometry created.
    • For geometry editing workflows, pass an existing Geometry into startWithGeometry(Geometry).
    • You can then edit the geometry directly on the map view using mouse or touch gestures.
    • The tool 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 geometry and stop each time.

    When started (started 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 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 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 geometry or selectedElement (for example selectVertex(int, int) or moveSelectedElement(Point)) are not affected by the settings in InteractionConfiguration.

    Change the appearance of the geometry by using the GeometryEditorStyle of the current 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 geometryChanged and selectedElementChanged to be notified when a user interaction or API call has changed the selectedElement or geometry. Changing the geometry state can also change canUndo, which triggers canUndoChanged.

    Starting a GeometryEditor and a SketchEditor in the same view at the same time is likely to cause unexpected behavior.

    Property Documentation

    [read-only] canRedo : bool

    true if there are actions that can be redone on the geometry, false otherwise (read-only).

    This applies to both programmatic and interactive changes to the geometry and is useful for enabling or disabling a UI control for redo actions.

    The value of canRedo changes, raising the canRedoChanged event, when:

    • an initial action that can be redone is performed in the GeometryEditor, or
    • the last remaining action that can be redone was redone

    See also redo and canUndo.


    [read-only] canUndo : bool

    true if there are actions that can be undone on the geometry, false otherwise (read-only).

    This applies to both programmatic and interactive changes to the geometry and is useful for enabling or disabling a UI control for undo actions.

    The value of canUndo changes, raising the canUndoChanged event, when:

    • an initial action that can be undone is performed in the GeometryEditor, or
    • the last remaining action that can be undone was undone

    See also undo and canRedo.


    [read-only] geometry : Geometry

    The current geometry, updated as you interact with the view (read-only).

    The geometry returned depends on the state of the GeometryEditor:

    The geometry is returned in the spatial reference of the associated MapView, if one is set. If there is no associated MapView, and the GeometryEditor was started by passing a geometry parameter to a start method, then the spatial reference of that geometry is used. If neither of these cases is true, the spatial reference of the geometry is null.

    The value of geometry changes, raising the geometryChanged, when:

    • starting or stopping the geometry editor - for example using start(Enums.GeometryType) or stop
    • performing programmatic edits - for example using insertVertex(Point) or GeometryEditor.deleteSelectedElement()
    • performing interactive edits - for example adding or moving a vertex
    • undoing or redoing edits - using undo or redo

    See also selectedElementChanged.


    [read-only] selectedElement : GeometryEditorElement

    The element that is currently selected in the GeometryEditor, or null if nothing is selected (read-only).

    Clicking or tapping on the different visible elements of a 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 tool.

    You can also programmatically select specific vertices (selectVertex(int, int)), mid-vertices (selectMidVertex(int, int)), parts of polygons or polylines (selectPart(int)), or the entire geometry (selectGeometry). You can clear the selection using clearSelection.

    The value of selectedElement changes, raising the selectedElementChanged event, when:

    • performing programmatic selection - for example using selectGeometry or GeometryEditor.selectVertex(int, int)
    • performing interactive selection - for example selecting or unselecting a GeometryEditorElement
    • the location of the selected element changes - for example moving the selected element programmatically or interactively
    • performing edits - for example inserting a vertex interactively or deleting the selected element programmatically

    It may also change when:

    • undoing or redoing edits - using undo or redo
    • stopping the geometry editor using stop

    [read-only] started : bool

    true if an editing session is active, false otherwise (read-only).

    When true, interactions with the view can affect the state of the geometry or selectedElement.

    Starting or stopping the GeometryEditor raises the startedChanged event.

    See also start(Geometry), start(Enums.GeometryType), and stop.


    The tool defining how you interact with the view to create and edit the geometry.

    The default value is a VertexTool with all interactive operations enabled, providing a common way of editing points, multipoints, polygons, and polylines.

    The tool can be replaced while a GeometryEditor is started (started = true), enabling a combination of tools to be used to edit a geometry.

    See also VertexTool, FreehandTool, and ShapeTool.


    visible : bool

    true if the geometry is visible in the view, false otherwise.

    See also visibleChanged.


    Signal Documentation

    canRedoChanged()

    Indicates that the value of canRedo changed.

    Note: The corresponding handler is onCanRedoChanged.


    canUndoChanged()

    Indicates that the value of canUndo changed.

    Note: The corresponding handler is onCanUndoChanged.


    geometryChanged()

    Indicates that the state of the geometry held by the GeometryEditor changed.

    Note: The corresponding handler is onGeometryChanged.


    selectedElementChanged()

    Indicates that the selected element of the GeometryEditor changed.

    Note: The corresponding handler is onSelectedElementChanged.


    startedChanged()

    Indicates that the value of started changed.

    Note: The corresponding handler is onStartedChanged.


    toolChanged()

    Emitted when the tool property changes.

    Note: The corresponding handler is onToolChanged.


    visibleChanged()

    Emitted when the visible property changes.

    Note: The corresponding handler is onVisibleChanged.


    Method Documentation

    void clearGeometry()

    Clears the current geometry being edited.

    Sets geometry to an empty geometry (Geometry::empty = true). The Enums.GeometryType is maintained - to edit a different type of geometry, restart the GeometryEditor with the required type.

    See also clearSelection.


    void clearSelection()

    Clears the current selection.

    This sets selectedElement to null. It does not change the geometry.

    See also clearGeometry.


    void deleteSelectedElement()

    Deletes the selected element from the current geometry.

    To clear the selection, but leave the state of the geometry unchanged, call clearSelection instead.

    See also selectedElement and InteractionConfiguration::allowDeletingSelectedElement.


    void insertVertex(Point point)

    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.

    • point - The location of the new vertex.

    If geometry is empty (Geometry::empty is true), the given point is added as the initial vertex, and then selected. If nothing is selected (selectedElement is null), the point is appended to the end of the geometry, and then selected. If selectedElement is the first vertex in a part of a Multipart, the given point is inserted before the currently selected vertex, and then selected.

    If geometry is a non-empty Point, this method replaces the existing point with the given point, and selects it.

    See also InteractionConfiguration::allowVertexCreation.


    void moveSelectedElement(Point newPoint)

    Moves the selected element to the specified location.

    • newPoint - The new location for the selected element.

    If selectedElement is a GeometryEditorVertex, then the location of the vertex is moved to the given point. If the selectedElement is any other type of GeometryEditorElement, then the center of the element is moved to the given point.

    See also InteractionConfiguration::allowMovingSelectedElement, moveSelectedElement, rotateSelectedElement, and scaleSelectedElement.


    void moveSelectedElementWithDelta(double deltaX, double deltaY)

    Moves the selected element by the specified distances along the x-axis and y-axis.

    • deltaX - The distance to move the selected element along the x-axis, in the units of the geometry spatial reference.
    • deltaY - The distance to move the selected element along the y-axis, in the units of the geometry spatial reference.

    See also InteractionConfiguration::allowMovingSelectedElement.


    void redo()

    Redoes the last action undone on the geometry.

    See also canRedo, undo, and canRedoChanged.


    void replaceGeometry(Geometry geometry)

    Replaces the current geometry with the specified geometry.

    • geometry - The new geometry to replace the current geometry. The Enums.GeometryType of these geometries must match.

    Use this method to make changes to the 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 geometry, use a MultipartBuilder to add the required part, and then pass the updated GeometryBuilder::geometry to this method.


    [since Esri.ArcGISRuntime 200.2] void rotateSelectedElement(double angle, Point origin)

    Rotates the selectedElement by the specified angle.

    • angle - The angle by which to rotate the selected element, counterclockwise, in degrees.
    • origin - The center of rotation. If null, the center of the extent of the selectedElement is used.

    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.

    If the origin Point has a different SpatialReference than the geometry, the point will be reprojected before the geometry is rotated, using the default transformation.

    If selectedElement is a GeometryEditorVertex, or a GeometryEditorGeometry of type Point, and the origin parameter is null (or is at the same location as the selected element), then rotating the selected element has no effect.

    This method was introduced in Esri.ArcGISRuntime 200.2.

    See also moveSelectedElementWithDelta(double, double), moveSelectedElement(Point), scaleSelectedElement(double, double, Point), InteractionConfiguration::allowRotatingSelectedElement, and GeometryEngine::rotate(Geometry, double, Point).


    [since Esri.ArcGISRuntime 200.2] void scaleSelectedElement(double scaleX, double scaleY, Point origin)

    Scales the selected element by the specified factors.

    • scaleX - The scale factor along the x-axis. It can be positive or negative. It cannot be 0, or a non-numeric value.
    • scaleY - The scale factor along the y-axis. It can be positive or negative. It cannot be 0, or a non-numeric value.
    • origin - The point relative to which the geometry will be scaled. If null, or Geometry::empty is true, the center of the extent of the selectedElement is used.

    If the origin Point has a different SpatialReference than the geometry, the point will be reprojected before the geometry is rotated, using the default transformation.

    Positive scale factors greater than 1 increase the size of the geometry, and positive factors between 0 and 1 reduce the size of the geometry. Negative scale factors produce a geometry reflected across the axes of the origin point. Negative factors less than -1 both reflect and increase the size of the geometry, and negative factors between -1 and 0 both reflect and reduce the size of the geometry.

    This method was introduced in Esri.ArcGISRuntime 200.2.

    See also moveSelectedElementWithDelta(double, double), moveSelectedElement(Point), rotateSelectedElement(double, Point), InteractionConfiguration::allowScalingSelectedElement, and GeometryEngine::scale(Geometry, double, double, Point).


    void selectGeometry()

    Selects the entire 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 moveSelectedElement(Point) or moveSelectedElementWithDelta(double, double) to move it programmatically.

    When the entire geometry is selected, the GeometryEditorGeometry returned from selectedElement has a geometry equal to geometry. If the geometry is a Point, then a GeometryEditorVertex is returned from selectedElement instead, which is equivalent to the entire geometry and provides immediate access to the x,y coordinates of the selected point geometry.

    See also InteractionConfiguration::allowGeometrySelection, clearSelection, selectVertex(int, int), selectMidVertex(int, int), and selectPart(int).


    void selectMidVertex(int partIndex, int segmentIndex)

    Selects mid-vertex with specified indices.

    • partIndex - The index of the part in the geometry editor's Multipart geometry that contains the mid-vertex to be selected. Use a value of 0 for non-multipart geometry types - Point and Multipoint.
    • segmentIndex - The index of segment that the mid-vertex to be selected lies on, within the given part of the geometry editor's Multipart geometry, or within the Multipoint geometry. Use a value of 0 for Point geometries.

    Mid-vertices do not exist in the 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.

    When a mid-vertex is selected, a GeometryEditorMidVertex is returned from selectedElement.

    See also InteractionConfiguration::allowMidVertexSelection, clearSelection, selectVertex(int, int), selectMidVertex(int, int), and selectGeometry.


    void selectPart(int partIndex)

    Selects part with specified index.

    • partIndex - The index of the part in the geometry editor's Multipart geometry to be selected. Use a value of 0 for Multipoint geometries.

    When a part of a polygon or polyline geometry is selected, a GeometryEditorPart is returned from selectedElement. If the polygon or polyline has only one part, then a GeometryEditorGeometry with a shape equivalent to the entire geometry is returned from selectedElement instead, which provides immediate access to the extent (Geometry::extent) and can be directly used in other geometry operations. If the current geometry is a Point or Multipoint, the entire geometry is selected.

    When a part of a Polygon or Polyline (Multipart) geometry is selected it can be edited separately from the other parts of the geometry. For example, you can move only the selected part interactively by dragging, or call moveSelectedElement(Point) or moveSelectedElementWithDelta(double, double) to move only the selected part programmatically.

    See also InteractionConfiguration::allowPartSelection, clearSelection, selectVertex(int, int), selectMidVertex(int, int), and selectGeometry.


    void selectVertex(int partIndex, int vertexIndex)

    Selects vertex with specified indices.

    • partIndex - The index of the part that contains the vertex (point)) to be selected, within the geometry editor's Multipart geometry. Use a value of 0 for Point and Multipoint (non-multipart geometries).
    • vertexIndex - The index of the vertex (point) to be selected, within the given part of the geometry editor's Multipart geometry, or within the Multipoint geometry. Use a value of 0 for Point geometries.

    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 moveSelectedElement(Point) or moveSelectedElementWithDelta(double, double) to move the selected vertex programmatically.

    When a vertex is selected, a GeometryEditorVertex is returned from selectedElement.

    See also InteractionConfiguration::allowVertexSelection, clearSelection, selectVertex(int, int), selectMidVertex(int, int), and selectGeometry.


    void startWithGeometry(Geometry initialGeometry)

    Starts a geometry editing session based on the specified geometry.

    • initialGeometry - The initial geometry to start the editing session with.

    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 tool and its InteractionConfiguration.


    void startWithGeometryType(Enums.GeometryType geometryType)

    Starts a geometry editing session with an empty geometry of the specified Enums.GeometryType.

    Use this method for data creation workflows, where you know the Enums.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 tool.

    GeometryEditor can be used to create Point, Multipoint, Polygon, and Polyline geometries - however FreehandTool, and ShapeTool are suitable for creating Polygon, and Polyline geometries only.


    Geometry stop()

    Stops the editing session by making the GeometryEditor no longer respond to user interaction and clears the geometry.

    See also geometry and geometryChanged.


    void undo()

    Undoes the last action on the geometry.

    See also canUndo and redo.


    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.