DrawAction
esri/views/2d/draw/DrawAction
DrawAction is the base class for all draw actions. DrawActions use the view events to generate a set of coordinates to create new geometries. Each serves a different purpose, allowing you to create a different type geometry such as point, multipoint, polyline, and polygon.
When the draw.create("type of geometry") method is called, an instance of the relevant draw action is returned. You can then listen to its events to create a new geometry that meets criteria specified by the application.
Property Overview
Name | Type | Summary | Class | |
---|---|---|---|---|
String | The name of the class. more details | more details | Accessor | |
MapView | A reference to the MapView. more details | more details | DrawAction |
Property Details
- Since: ArcGIS API for JavaScript 4.7
The name of the class. The declared class name is formatted as
esri.folder.className
.
Method Overview
Name | Return Type | Summary | Class | |
---|---|---|---|---|
Boolean | Indicates if the redo() method can be called on the action instance. more details | more details | DrawAction | |
Boolean | Indicates if the undo() method can be called on the action instance. more details | more details | DrawAction | |
Emits an event on the instance. more details | more details | DrawAction | ||
Boolean | Indicates whether there is an event listener on the instance that matches the provided event name. more details | more details | DrawAction | |
Object | Registers an event handler on the instance. more details | more details | DrawAction | |
Incrementally redo actions recorded in the stack. more details | more details | DrawAction | ||
Incrementally undo actions recorded in the stack. more details | more details | DrawAction |
Method Details
- canRedo(){Boolean}
Indicates if the redo() method can be called on the action instance.
Returns:Type Description Boolean Returns true
if the redo() method can be called.
- canUndo(){Boolean}
Indicates if the undo() method can be called on the action instance.
Returns:Type Description Boolean Returns true
if the undo() method can be called.
- emit(type, event)
Emits an event on the instance. This method should only be used when creating subclasses of this class.
Parameters:type StringThe name of the event.
event ObjectThe event payload.
- hasEventListener(type){Boolean}
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameter:type StringThe name of the event.
Returns:Type Description Boolean Returns true if the class supports the input event.
- on(type, listener){Object}
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters:type StringThe name of event to listen for.
listener FunctionThe function to call when the event is fired.
Returns:Type Description Object Returns an event handler with a remove()
method that can be called to stop listening for the event.Property Type Description remove Function When called, removes the listener from the event. - See also:
Example:view.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint); });
- redo()
Incrementally redo actions recorded in the stack. Call canRedo() prior to calling this method to check if this method can be called on the action instance. Calling this method will fire the vertex-add or vertex-remove events depending on the last action.
Example:if (action.canRedo()) { action.redo(); }
- undo()
Incrementally undo actions recorded in the stack. Call canUndo() prior to calling this method to check if this method can be called on the action instance. Calling this method will fire the vertex-add or vertex-remove events depending on the last action.
Example:if (action.canUndo()) { action.undo(); }