Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Implements

Overview

Constructors

constructor

Events

on

  • (event: "Restarted", callback: () => void): Handle
  • (event: "EditShape", callback: (event: EditShapeEvent) => void): Handle
  • (event: "Invalidated", callback: () => void): Handle
  • (event: "Activated", callback: (map: Map) => void): Handle
  • (event: "Deactivated", callback: (map: Map) => void): Handle

Accessors

Protected cursor

  • get cursor(): string | null
  • set cursor(cssCursor: string | null): void
  • 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.

    see

    Map.cursorManager

    since

    2022.1

    Returns 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.

    see

    Map.cursorManager

    since

    2022.1

    Parameters

    • cssCursor: string | null

    Returns any

feature

  • The feature being edited by this controller.

    since

    2022.1

    Returns Feature

layer

  • The layer being edited by this controller.

    since

    2022.1

    Returns FeatureLayer

map

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

    Returns Map | null

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

    Parameters

    • _value: Map | null

    Returns any

Methods

getMaximumPointCount

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

    see

    setPointCount

    Returns number

getMinimumPointCount

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

    see

    setPointCount

    Returns number

getSettings

  • Returns the settings configured on this EditController. These settings are passed to the Editor and its handles, through 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 Editor and 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);
    
    since

    2022.1

    Returns EditSettings

invalidate

  • (): void
  • 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

onActivate

  • (map: Map): void

onDeactivate

  • (aMapView: Map): Promise<void> | void

onDraw

onDrawLabel

onGestureEvent

onKeyEvent

  • 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.

restart

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

    2022.1

    Parameters

    • feature: Feature

      The feature to restart editing for

    • layer: FeatureLayer

      The layer to restart editing for. Must be editable.

    Returns void

setPointCount

  • (aMinimumPointCount: number, aMaximumPointCount: number): void
  • 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

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method