Controller used to graphically edit existing objects in a layer on the view.

Editing is supported for all shapes available in ShapeFactory. Supported editing operations include moving the entire shape, moving individual vertices or control points, adding vertices, and deleting vertices.

Editing is supported on regular 2D maps as well as WebGL 2D or 3D maps.

However, only 2D shapes or 2D aspects of 3D shapes are editable. For example, you can edit the base shape of an extruded shape.

If you want to add undo/redo support to the EditController, check out the Adding undo/redo support to your application guide.

If you want to change the way editing behaves, check out the Customizing creation and editing guide.

Hierarchy

Constructors

Accessors

  • get cursor(): null | string
  • The CSS cursor to use on the map, for this controller. If null, the map will fall back to the previous cursor that was set on the map.

    Note that changing this cursor will update the cursor on the map's DOM node. When using multiple controllers (e.g. in a CompositeController), the controller that updates the cursor last (to a non-null value), will override any other non-null cursors of active controllers on the map.

    Returns null | string

    See

    Map.cursorManager

    Since

    2022.1

  • set cursor(cssCursor): void
  • Parameters

    • cssCursor: null | string

    Returns void

  • get map(): null | Map
  • The map on which this controller is currently active or null if this controller is not currently active. This property is read-only.

    Returns null | Map

  • set map(_value): void
  • Parameters

    • _value: null | Map

    Returns void

Methods

  • Return the maximum number of points that should be allowed during editing.

    Returns number

  • Return the minimum number of points that should be allowed during editing.

    Returns number

  • Returns the settings configured on this EditController. These settings are passed to the EditContext.settings.

    You can override this to add additional settings. For example, a custom constraint like a minimum and maximum radius of a circle. LuciadRIA will add these additional settings to EditContext.settings, which is passed to the EditHandles.

    interface ConstrainedCircleEditorSettings2 extends EditSettings {
    minRadius: number;
    maxRadius: number;
    }

    class ConstrainedCircleEditController extends EditController {

    private readonly _minRadius: number;
    private readonly _maxRadius: number;

    constructor(layer: FeatureLayer, feature: Feature, minRadius: number, maxRadius: number) {
    super(layer, feature, {editor: new ConstrainedCircleEditor2()});
    this._minRadius = minRadius;
    this._maxRadius = maxRadius;
    }

    getSettings(): ConstrainedCircleEditorSettings2 {
    return {
    ...super.getSettings(),
    minRadius: this._minRadius,
    maxRadius: this._maxRadius
    };
    }
    }

    class ConstrainedCircleEditor2 extends CircleByCenterPointEditor {

    createRadiusHandle(context: EditContext): EditHandle {
    const settings = context.settings as ConstrainedCircleEditorSettings2;
    const circle = context.feature.shape as CircleByCenterPoint;

    const geodesy = (circle.reference?.referenceType === ReferenceType.GEODETIC)
    ? createEllipsoidalGeodesy(circle.reference) : createCartesianGeodesy(circle.reference!);

    let radiusPointAzimuth = 90;
    return new PointDragHandle(
    (): Point => geodesy.interpolate(circle.center, circle.radius, radiusPointAzimuth),
    (point: Point): void => {
    const distance = geodesy.distance(circle.center, point);
    circle.radius = Math.max(settings.minRadius, Math.min(settings.maxRadius, distance));

    radiusPointAzimuth = geodesy.forwardAzimuth(circle.center, point);
    });
    }
    }

    const MIN_RADIUS = 1e3;
    const MAX_RADIUS = 5e3;
    map.controller = new ConstrainedCircleEditController(layer, feature, MIN_RADIUS, MAX_RADIUS);

    Returns EditSettings

    Since

    2022.1

  • Call this method to indicate that the controller's appearance has changed. Calling this method ensures the onDraw will be called during the next rendering pass.

    Returns void

  • Callback that is invoked when this controller is activated on a map. This method allows controller implementations to perform setup work.

    Parameters

    • map: Map

      the map on which the controller has been activated

    Returns void

  • Callback that is invoked when this controller is deactivated on a map. This method allows controller implementations to perform cleanup work. This method must return either any resolved value or a promise to indicate completion of deactivation. This allows controller implementation to perform asynchronous deactivation work. During the period between this method being called and the resolution of the deactivation promise, this controller will no longer receive input events, but will still get the opportunity to draw itself.

    Parameters

    • aMapView: Map

      the map on which the controller has been deactivated

    Returns void | Promise<void>

    a concrete value to indicate immediate deactivation or a deactivation promise.

  • Callback that allows controller implementations to perform custom drawing on the map. Controller shapes and icons are drawn on top of all other content in the map. Note that the map may perform caching which may cause this method to only be invoked once. When a controller implementation's appearance changes the implementation should call invalidate on itself.

    Parameters

    • aGeoCanvas: GeoCanvas

      the GeoCanvas on which the controller can draw shapes.

    Returns void

  • Callback that allows controller implementations to draw labels on the map. Note that the map may perform caching which may cause this method to only be invoked once. When a controller implementation's appearance changes the implementation should call invalidate on itself.

    Parameters

    • labelCanvas: LabelCanvas

      the LabelCanvas on which the controller can draw labels.

    Returns void

  • Called when a gesture event has been received. This method must return a HandleEventResult value to indicate if the event was handled or not, If this method returns EVENT_IGNORED, the map will be given the opportunity to perform default gesture event behaviour. If default event handling is not desired, this method should return EVENT_HANDLED. (See the Controller class description for the default behavior.)

    Parameters

    Returns HandleEventResult

    the gesture event handling result.

  • Called when a key event has been received. This method must return a HandleEventResult value to indicate if the event was handled or not, If this method returns EVENT_IGNORED, the map will be given the opportunity to perform default key event behaviour. If default event handling is not desired, this method should return EVENT_HANDLED. (See the Controller class description for the default behavior.)

    Parameters

    • keyEvent: KeyEvent

      The key event to be handled. Note that this is a KeyEvent and not a DOMEvent. You can access the corresponding DOMEvent through KeyEvent.domEvent.

    Returns HandleEventResult

    The key event handling result.

  • Immediately restarts editing for the given feature and layer. This can be used to force editing to a specific shape. For example, to apply an undo step or to synchronize the edited shape with coordinates from a form.

    The feature that was currently being edited will not be updated in the model.

    function synchronizeEditControllerWithForm() {
    const newShape = createShapeFromFormValues(); // implemented in your code
    feature.shape = newShape;
    editController.restart(feature, layer);
    }

    Parameters

    Returns void

    Since

    2022.1

  • Set the minimum and maximum number of points that should be allowed during editing using this controller. Once the maximum number of points is reached, the controller will not allow insertion of new points. Once the minimum number of points is reached, the controller will not allow deletion of new points. Note that this method should be called before the edit controller is activated on the map, subsequent calls to this method will be ignored.

    Parameters

    • aMinimumPointCount: number

      The minimum number of points that should be allowed during editing.

    • aMaximumPointCount: number

      The maximum number of points that should be allowed during editing. Set to -1 if not specified.

    Returns void

Events

"Restarted" event

  • on("Restarted", callback: (() => void)) : Handle
  • An event that fires whenever EditController.restart was called.

    Use this event to get notified whenever something external (like an undoable) restarts this EditController (ie. changes its shape / feature).

    Parameters

    • event: "Restarted"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns Handle

    See

    Controller.on Restarted

    Since

    2022.1

"EditShape" event

  • on("EditShape", callback: ((event) => void)) : Handle
  • An event that fires whenever the user edited the shape.

    You can use this event to create "edit shape" undoables. See the Adding undo/redo support to your application guide for more information on how to work with undo/redo in LuciadRIA.

    Parameters

    • event: "EditShape"
    • callback: ((event) => void)

    Returns Handle

    See

    Controller.on EditShape

    Since

    2022.1

"Invalidated" event

  • on("Invalidated", callback: (() => void)) : Handle
  • Parameters

    • event: "Invalidated"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns Handle

    See

    Controller.on Invalidated

"Activated" event

  • on("Activated", callback: ((map) => void)) : Handle
  • Parameters

    • event: "Activated"
    • callback: ((map) => void)
        • (map): void
        • Parameters

          Returns void

    Returns Handle

    See

    Controller.on Activated

"Deactivated" event

  • on("Deactivated", callback: ((map) => void)) : Handle
  • Parameters

    • event: "Deactivated"
    • callback: ((map) => void)
        • (map): void
        • Parameters

          Returns void

    Returns Handle

    See

    Controller.on Deactivated