Creates a new edit controller
the layer in which to edit an object
the feature to edit
An options object hash containing EditController
options.
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.
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.
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.
The feature being edited by this controller.
The layer being edited by this controller.
The map on which this controller is currently active or null
if this controller is not currently active.
This property is read-only.
The map on which this controller is currently active or null
if this controller is not currently active.
This property is read-only.
Return the maximum number of points that should be allowed during editing.
Return the minimum number of points that should be allowed during editing.
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);
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.
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.
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.
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.