LuciadRIA (2026.0.04)
    Preparing search index...

    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 both 2D and 3D maps.

    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 (View Summary)

    Constructors

    Accessors

    • get cursor(): string | null

      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 string | null

      2022.1

    • set cursor(cssCursor: string | null): void

      Parameters

      • cssCursor: string | null

      Returns void

    • get editor(): Editor

      Return the editor used by this controller

      Returns Editor

      2026.0.1

    • get feature(): Feature

      The feature being edited by this controller.

      Returns Feature

      2022.1

    • get map(): RIAMap | null

      The map on which this controller is currently active or null if this controller is not currently active. This property is read-only.

      Returns RIAMap | null

    • set map(_value: RIAMap | null): void

      Parameters

      Returns void

    Methods

    • Finishes the editing process.

      This calls the onFinish hook and handles its result. The edit controller stays active. To deactivate, call:

      map.controller = null.
      

      Returns void

      2024.0

    • 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);

      Note in this case, it is important to also keep these default settings, because without them, the default editors might no longer work as expected. You can do that like this:

      getSettings(): YourCustomSettings {
      return {
      ...super.getSettings(),
      yourCustomSetting: yourCustomValue,
      }
      }

      Your own custom settings should also extend the EditSettings

      Returns EditSettings

      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: RIAMap

        the map on which the controller has been activated

      Returns void

    • 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

      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 whenever an edit operation finishes.

      By default, this calls WorkingSet.put on the layer's workingSet to update the feature in the layer/model. This will return a Promise if there is an asynchronous WorkingSet.put operation on-going.

      Returns void | Promise<void>

      2024.0

    • 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

      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

    • 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

      Returns Handle

      Controller.on Restarted

      2022.1

    • 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

      Returns Handle

      Controller.on EditShape

      2022.1

    • An event that fires whenever the user edits a property of the feature.

      This event isn't fired by any of the default LuciadRIA edit handles, but a custom handle can emit an EditProperty event.

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

      Parameters

      Returns Handle

      Controller.on EditProperty

      2026.0

    • Parameters

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

      Returns Handle

      Controller.on Invalidated

    • Parameters

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

      Returns Handle

      Controller.on Activated

    • Parameters

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

      Returns Handle

      Controller.on Deactivated