Constructs a new BasicCreateController.
The type of shape that must be created.
Optional
defaultProperties: FeaturePropertiesAn optional object hash containing the properties that should be set on newly created features.
Optional
options: CreateControllerConstructorOptionsan optional object hash containing general create controller 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.
Finishes the creation process.
This calls the onObjectCreated hook. The creation controller stays active. To deactivate, call:
map.controller = null.
2024.0
Returns the settings configured on this CreateController. These settings are passed to the EditContext.settings.
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
This method is called when this controller needs to determine in which
layer an object should be created. This method can be overridden to choose
a specific layer. If this method returns null
then the object creation will
not be started. This controller will remain the active controller though.
the map
the layer to create objects for or null
Called when a new feature instance needs to be created. This implementation will create a new Feature with an empty geometry of the type that was given at construction time. The properties of the feature will be populated with the values, if any, that were given at construction of the BasicCreateController.
the map view
the layer
a new feature
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.
Called when a complete feature has been created.
The BasicCreateController will delegate to CreateController.onObjectCreated only if a shape has been created. For example, if the controller is deactivated before the user constructed a shape, the feature will not be added to the model.
The default implementation of this method adds the created object to the model of the given layer. When the return istrue
, the controller will deactivate immediately.
When the return is a Promise
, the controller will deactivate when the promise is resolved or when the promise is rejected.
When a Promise
is returned, the controller will deactivate when the promise is resolved or when the promise is rejected.
When no Promise
is returned, the controller will deactivate immediately.
Set the minimum and maximum number of points that should be created using this controller. Once the maximum number of points is reached, the controller will automatically disable itself. Note that this method should be called before the creation controller is activated on the map, subsequent calls to this method will be ignored.
The minimum number of points that should be created. Has to be positive.
The maximum number of points that should be created. Set to -1 if not specified.
An event that fires whenever CreateController.restart was called.
An event that fires whenever the user edited the shape. EditShape
2022.1
Controller.on Invalidated
Controller.on Activated
Controller.on Deactivated
A basic create controller implementation that creates shapes based on a shape type that is passed to the constructor. Most shapes available in ShapeFactory are supported.
The minimum point count is set to 3 for polygons and 2 for polylines by default. You can set the minimum and maximum number of points that should be created by this controller by using the CreateController.setPointCount method.
Note that creation of complex polygons, shape lists, extruded shapes and oriented boxes is not supported by this controller.