Creates a new edit controller
the layer in which to edit an object
the feature to edit
Optional
options: EditControllerConstructorOptionsAn options object hash containing EditController
options.
Protected
cursorThe 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.
The feature being edited by this controller.
2022.1
The layer being edited by this controller.
2022.1
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);
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.
Callback that is invoked when this controller is activated on a map. This method allows controller implementations to perform setup work.
the map on which the controller has been activated
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.
the map on which the controller has been deactivated
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.
the GeoCanvas on which the controller can draw shapes.
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.
the LabelCanvas on which the controller can draw labels.
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.)
The gesture event to be handled. Note that this is a GestureEvent and not a DOMEvent. You can access the corresponding DOMEvent through GestureEvent.domEvent.
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.)
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.
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);
}
The feature to restart editing for
The layer to restart editing for. Must be editable.
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.
The minimum number of points that should be allowed during editing.
The maximum number of points that should be allowed during editing. Set to -1 if not specified.
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).
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.
Controller.on Invalidated
Controller.on Activated
Controller.on Deactivated
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.