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.
Constructors
-
new DrawAction(properties)
-
Parameter:properties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class | |
---|---|---|---|---|
String | more details The name of the class. | more details | Accessor | |
Boolean | more details Controls whether the created geometry will have z coordinates or not. | more details | DrawAction | |
Number[][] | more details Two-dimensional array of numbers representing the coordinates of each vertex comprising the geometry being drawn. | more details | DrawAction | |
MapView | more details A reference to the MapView. | more details | DrawAction |
Property Details
-
The name of the class. The declared class name is formatted as
esri.folder.className
.
-
hasZ Boolean
-
Controls whether the created geometry will have z coordinates or not.
- Default Value:true
-
Two-dimensional array of numbers representing the coordinates of each vertex comprising the geometry being drawn.
Method Overview
Name | Return Type | Summary | Class | |
---|---|---|---|---|
Boolean | more details Indicates if the redo() method can be called on the action instance. | more details | DrawAction | |
Boolean | more details Indicates if the undo() method can be called on the action instance. | more details | DrawAction | |
Boolean | more details Emits an event on the instance. | more details | DrawAction | |
FromScreenPointResult|null | more details Maps the given screen point to a map point. | more details | DrawAction | |
Number[]|null | more details Maps the given screen point to a map point. | more details | DrawAction | |
Boolean | more details Indicates whether there is an event listener on the instance that matches the provided event name. | more details | DrawAction | |
Object | more details Registers an event handler on the instance. | more details | DrawAction | |
more details Incrementally redo actions recorded in the stack. | more details | DrawAction | ||
Point|null | more details Maps the given screen point to a map point. | more details | DrawAction | |
more details Incrementally undo actions recorded in the stack. | 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){Boolean}
-
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 ObjectoptionalThe event payload.
Returns:Type Description Boolean true
if a listener was notified
-
getCoordsAndPointFromScreenPoint(screenPoint){FromScreenPointResult|null}
-
Maps the given screen point to a map point.
Parameter:screenPoint ScreenPointThe location on the screen.
Returns:Type Description FromScreenPointResult | null The result object containing, or null
if the screen point could not be mapped.
-
Maps the given screen point to a map point.
Parameter:screenPoint ScreenPointThe location on the screen.
Returns:Type Description Number[] | null Array of x,y and z component (if hasZ is enabled) of the point associated with the given screen point or null
if screen point could not be mapped.
-
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:An event or an array of events to listen for.
listener FunctionThe function to call when the event fires.
Returns:Type Description Object Returns an event handler with a remove()
method that should be called to stop listening for the event(s).Property Type Description remove Function When called, removes the listener from the event. 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(); }
-
Maps the given screen point to a map point.
Parameter:screenPoint ScreenPointThe location on the screen.
Returns:Type Description Point | null MapPoint associated with the given screen point or null if screen point could not be mapped.
-
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(); }
Type Definitions
-
FromScreenPointResult
-
The result object of the getCoordsAndPointFromScreenPoint() method. See the table below for more details on each property.
- Properties:
-
Array of x, y, and z component (if hasZ is enabled).
mapPoint PointThe map point of the point associated with the given screen point.