require(["esri/views/draw/DrawAction"], (DrawAction) => { /* code goes here */ });
import DrawAction from "@arcgis/core/views/draw/DrawAction.js";
esri/views/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.
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
The name of the class. | Accessor | ||
Controls whether the created geometry will have z coordinates or not. | DrawAction | ||
Two-dimensional array of numbers representing the coordinates of each vertex comprising the geometry being drawn. | DrawAction | ||
A reference to the MapView. | DrawAction |
Property Details
-
hasZ
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 |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
Indicates if the redo() method can be called on the action instance. | DrawAction | ||
Indicates if the undo() method can be called on the action instance. | DrawAction | ||
Emits an event on the instance. | DrawAction | ||
Maps the given screen point to a map point. | DrawAction | ||
Maps the given screen point to a map point. | DrawAction | ||
Indicates whether there is an event listener on the instance that matches the provided event name. | DrawAction | ||
Returns true if a named group of handles exist. | Accessor | ||
Registers an event handler on the instance. | DrawAction | ||
Incrementally redo actions recorded in the stack. | DrawAction | ||
Removes a group of handles owned by the object. | Accessor | ||
Maps the given screen point to a map point. | DrawAction | ||
Incrementally undo actions recorded in the stack. | DrawAction |
Method Details
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, addHandles added at 4.25. -
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
getCoordsAndPointFromScreenPoint
getCoordsAndPointFromScreenPoint(screenPoint){FromScreenPointResult |null}
-
Maps the given screen point to a map point.
ParameterscreenPoint ScreenPointThe location on the screen.
ReturnsType 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.
ParameterscreenPoint ScreenPointThe location on the screen.
Returns
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
on
on(type, listener){Object}
-
Registers an event handler on the instance. Call this method to hook an event with a listener.
ParametersReturnsType 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. Exampleview.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint); });
-
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.
Exampleif (action.canRedo()) { action.redo(); }
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
Maps the given screen point to a map point.
ParameterscreenPoint ScreenPointThe location on the screen.
Returns
-
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.
Exampleif (action.canUndo()) { action.undo(); }
Type Definitions
-
The result object of the getCoordsAndPointFromScreenPoint() method. See the table below for more details on each property.