import type { State, SketchCreateEventState, SketchUpdateEventState, Layout, ToolbarKind } from "@arcgis/core/widgets/Sketch/types.js";Type definitions
SketchCreateEventState
- Since
- ArcGIS Maps SDK for JavaScript 5.0
- Type
- "start" | "active" | "complete" | "cancel"
SketchUpdateEventState
- Since
- ArcGIS Maps SDK for JavaScript 5.0
- Type
- "start" | "active" | "complete"
SelectionTool
- Since
- ArcGIS Maps SDK for JavaScript 5.0
- Type
- "lasso-selection" | "rectangle-selection" | "custom-selection"
SketchPolylineSymbol
- Since
- ArcGIS Maps SDK for JavaScript 5.0
- Type
- SimpleLineSymbol | LineSymbol3D | CIMSymbol
SketchPolygonSymbol
- Since
- ArcGIS Maps SDK for JavaScript 5.0
- Type
- SimpleFillSymbol | PolygonSymbol3D | CIMSymbol
UndoEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
graphics
- Type
- Graphic[]
- Since
- ArcGIS Maps SDK for JavaScript 5.0
An array of graphics that are being updated or created.
tool
- Type
- CreateTool | UpdateTool
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Name of the create or update tool that is active.
RedoEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
graphics
- Type
- Graphic[]
- Since
- ArcGIS Maps SDK for JavaScript 5.0
An array of graphics that are being updated or created.
tool
- Type
- CreateTool | UpdateTool
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Name of the create or update tool that is active.
CreationMode
- Since
- ArcGIS Maps SDK for JavaScript 5.0
- Type
- "single" | "continuous" | "update"
CreateOptions
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Options used by the create workflow.
graphicSymbol
- Type
- SymbolUnion | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The symbol the newly created graphic should use instead of the default symbol for the specified tool.
mode
- Type
- DrawingMode | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Specifies how the graphic can be created. The create mode applies only when creating
polygon, polyline, rectangle and circle geometries.
| Value | Description |
|---|---|
| hybrid | Vertices are added while the pointer is clicked or dragged. Applies to polygon and polyline. |
| freehand | Vertices are added while the pointer is dragged. Applies to polygon, polyline rectangle and circle. Default for rectangle and circle. |
| click | Vertices are added when the pointer is clicked. Applies to polygon, polyline rectangle and circle. Default for polygon and polyline. |
CreateTool
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Create operation DrawAction tool
- Type
- "point" | "multipoint" | "polyline" | "polygon" | "circle" | "rectangle" | "mesh" | "freehandPolyline" | "freehandPolygon" | "text"
CreateToolEventInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
This information is returned as toolEventInfo parameter for the Sketch.@create event when the graphic
is being created. It returns VertexAddEventInfo
when the user clicks the view or CursorUpdateEventInfo or when the user moves the cursor.
CreateEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
state
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The current state of the event.
Possible Values
| Value | Description |
|---|---|
| start | State changes to start when the first vertex is created. Not applicable when creating points. |
| active | State is active while feature is being created. Not applicable when creating points. |
| complete | State changes to complete after the Sketch.complete() method is called, when the user double clicks, presses the Enter key or clicks the first vertex of the polygon while creating a feature. When point is created, the a single sketch-create event is fired with the complete state. |
| cancel | State changes to cancel if the user presses the escape key or the Sketch.create() or Sketch.cancel() methods are called during the create operation and before the state changes to complete. |
toolEventInfo
- Type
- CreateToolEventInfo | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Returns additional information associated with
the create operation such as where the user is clicking the view or where the user is moving the cursor to.
Value of this parameter changes to null when the create event's state changes to complete or cancel.
ReshapeOptions
- Since
- ArcGIS Maps SDK for JavaScript 5.0
edgeOperation
- Type
- "none" | "offset" | "split" | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Sets the reshape operation on the edge. This affects lines and polygons. Fully supported in 3D, partially in 2D.
| Value | Description |
|---|---|
| none | No manipulators show up on the edge. (2D and 3D) |
| split | Manipulators show up to split edges by adding a new vertex. (2D and 3D) |
| offset | Manipulators show up to offset the edges. (only 3D) |
- Default value
- "split"
shapeOperation
- Type
- "none" | "move" | "move-xy" | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Sets the move constraints for the whole shape. Supported in 2D and 3D.
| Value | Description |
|---|---|
| none | No move manipulator show up. (2D and 3D) |
| move | Move manipulator show up to move in xy and in z. (2D and 3D) |
| move-xy | Move manipulator show up to move in xy only. (only 3D) |
- Default value
- "move"
vertexOperation
- Type
- "move" | "move-xy" | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Sets the move constraints for the vertex. Only supported in 3D.
| Value | Description |
|---|---|
| move | Move manipulator show up to move in xy and in z. |
| move-xy | Move manipulator show up to move in xy only. |
- Default value
- "move"
TransformOptions
- Since
- ArcGIS Maps SDK for JavaScript 5.0
preserveAspectRatio
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates if the uniform scale operation will be enabled when updating graphics. enableScaling
must be set true when setting this property to true. Only applies if tool is transform and is always true when transforming points that use a 3D object symbol layer.
- Default value
- false
UpdateOptions
- Since
- ArcGIS Maps SDK for JavaScript 5.0
- Supertypes
- MoveOptions ‚ TransformOptions
tool
- Type
- UpdateTool | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Name of the update tool. Specifies the update operation for the selected graphics. The provided tool will become the Sketch.activeTool.
Possible Values
| Value | Description |
|---|---|
| transform | This is the default tool for graphics with a Polygon geometry, Polyline geometry or graphics that use a 3D object symbol layer with a Point geometry. It allows one or multiple graphics to be scaled, rotated and moved by default. Its default behavior can be changed by setting the enableRotation, enableScaling or preserveAspectRatio arguments when calling the update method or setting them on the Sketch.defaultUpdateOptions property when the Sketch widget initializes. |
| reshape | This tool allows the entire graphic or individual vertices of the graphic to be moved. Vertices can be added or removed. This tool can only be used with a single graphic that has a Polygon or Polyline geometry. |
| move | This is the default tool for graphics with a Point geometry that do not use a 3D object symbol layer. It should be used for specific cases where you just want to move selected polygon and polyline graphics without additional options. Additionally, the move tool does not support toggling to different modes, since the move operation is built into both the transform and reshape tools by default. |
reshapeOptions
- Type
- ReshapeOptions | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Changes the behavior for the reshape tool. Defines the operations for edge and/or the constraints for moving a shape and/or a vertex. Only supported in 3D.
highlightOptions
- Type
- HighlightOptions | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Options that control when to display or hide highlights for update operations.
UpdateTool
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Update operation component
- Type
- "move" | "transform" | "reshape"
UpdateToolEventInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
This information is returned as toolEventInfo parameter for the Sketch.@update event when the user is updating graphics.
UpdateEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
graphics
- Type
- Graphic[]
- Since
- ArcGIS Maps SDK for JavaScript 5.0
An array of graphics that are being updated.
state
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The state of the event.
Possible Values
| Value | Description |
|---|---|
| start | State changes to start when a graphic is selected to be updated. |
| active | State is active while graphics are being updated and toolEventInfo parameter is not null. |
| complete | State changes to complete after graphics are updated. |
aborted
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Indicates if the update operation was aborted. Set to true
if the user pressed the escape key, or when the Sketch.update(), Sketch.create()
or Sketch.cancel() method is called before the update event's state changes to complete.
tool
- Type
- UpdateTool
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Name of the update operation tool.
toolEventInfo
- Type
- UpdateToolEventInfo | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Update operation tool info.
Returns additional information associated with the update operation that is taking place for selected graphics
and what stage it is at. Value of this parameter changes to null when the update event's state changes to complete.
MoveEventInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
This information is returned as toolEventInfo parameter for the Sketch.@update
event while the user is moving the graphics. It returns additional information associated with the move operation
and what stage it is at.
dx
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Number of pixels moved on the x-axis from the last known position.
dy
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Number of pixels moved on the y-axis from the last known position.
type
- Type
- "move-start" | "move" | "move-stop"
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Returns information indicating the stage of the move operation.
Possible Values
| Value | Description |
|---|---|
| move-start | The type changes to move-start at the start of move operation. |
| move | The type changes to move while graphics are being moved. |
| move-stop | The type changes to move-stop once graphics are moved. |
- Example
- // listen to update eventsketch.on("update", function(event){// check if the graphics are done being moved, printout dx, dy parameters to the console.const eventInfo = event.toolEventInfo;if (eventInfo && eventInfo.type.includes("move")){console.log(eventInfo.type, eventInfo.dx, eventInfo.dy);}});
ReshapeEventInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
This information is returned as toolEventInfo parameter for the Sketch.@update
event while the user is reshaping the graphics. It returns additional information associated with the reshape operation
and what stage it is at.
type
- Type
- "reshape-start" | "reshape" | "reshape-stop"
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Returns information indicating the stage of the reshape operation.
Possible Values
| Value | Description |
|---|---|
| reshape-start | The type changes to reshape-start at the start of reshape operation. |
| reshape | The type changes to reshape while graphics are being reshaped. |
| reshape-stop | The type changes to reshape-stop once graphics are reshaped. |
- Example
- // listen to update eventsketch.on("update", function(event){// check if the graphics are done being reshaped, printout updated graphic's geometry and reshape stage.const eventInfo = event.toolEventInfo;if (eventInfo && eventInfo.type.includes("reshape")) {console.log(eventInfo.type, event.graphics[0].geometry);}});
RotateEventInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
This information is returned as toolEventInfo parameter for the Sketch.@update
event while the user is rotating the graphics. It returns additional information associated with the rotate operation
and what stage it is at.
type
- Type
- "rotate-start" | "rotate" | "rotate-stop"
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Returns information indicating the stage of the rotate operation.
Possible Values
| Value | Description |
|---|---|
| rotate-start | The type changes to rotate-start at the start of rotate operation. |
| rotate | The type changes to rotate while graphics are being rotated. |
| rotate-stop | The type changes to rotate-stop once graphics are rotated. |
- Example
- // listen to update eventsketch.on("update", function(event){if (event.tool === "transform") {if (event.toolEventInfo) {const info = event.toolEventInfo,type = info.type;// rotate events onlyif (type.includes("rotate")) {// check if the rotation angle exceeded 45if (info.angle > 45) {// complete the graphic update operationsketch.complete();}}}}});
ScaleEventInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
This information is returned as toolEventInfo parameter for the Sketch.@update
event while the user is scaling or resizing the graphics. It returns additional information associated with the scale
operation and what stage it is at.
type
- Type
- "scale-start" | "scale" | "scale-stop"
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Returns information indicating the stage of the scale operation.
Possible Values
| Value | Description |
|---|---|
| scale-start | The type changes to scale-start at the start of scale or resize operation. |
| scale | The type changes to scale while graphics are being scaled or resized. |
| scale-stop | The type changes to scale-stop once graphics are scaled or resized. |
xScale
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The x scale factor used to enlarge or shrink the geometry.
yScale
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The y scale factor used to enlarge or shrink the geometry.
VertexInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
coordinates
- Type
- number[]
- Since
- ArcGIS Maps SDK for JavaScript 5.0
An array of x,y coordinates representing the vertices added/removed.
componentIndex
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The ring/path index of the added/removed vertex.
vertexIndex
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The index of the vertex position.
VertexAddEventInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
This information is returned as toolEventInfo parameter for the Sketch.@create
or Sketch.@update event when the user adds vertices to the graphic being created or updated.
vertices
- Type
- VertexInfo[]
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Contains the details of the added vertices to track changes in topology of the geometry.
- Example
- // listen to create eventsketch.on("create", function(event){// check if vertices are being added to the graphic that is being updated.if (event.toolEventInfo && event.toolEventInfo.type === "vertex-add"){const addedPoint = event.toolEventInfo.added[0].geometry;console.log(event.toolEventInfo.type, addedPoint.x, addedPoint.y);}});
VertexRemoveEventInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
This information is returned as toolEventInfo parameter for the Sketch.@update event
when the user is removing vertices from the graphic.
vertices
- Type
- VertexInfo[]
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Contains the details of the removed vertices to track changes in topology of the geometry.
- Example
- // listen to update eventsketch.on("update", function(event){// check if vertices are being added to the graphic that is being updated.const eventInfo = event.toolEventInfo;if (eventInfo && eventInfo.type === "vertex-remove"){const removedPoint = eventInfo.removed[0].geometry;console.log(eventInfo.type, removedPoint.x,removedPoint.y);}});
CursorUpdateEventInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
This information is returned as toolEventInfo parameter for the Sketch.@create
event when the user moves the cursor on the view while the graphic is being created.
coordinates
- Type
- number[]
- Since
- ArcGIS Maps SDK for JavaScript 5.0
An array of numbers representing the coordinates of the cursor location.
- Example
- // listen to create eventsketch.on("create", function(event){// respond to create event while the cursor is being moved on the view.const eventInfo = event.toolEventInfo;if (eventInfo && eventInfo.type === "cursor-update"){console.log(eventInfo.type, eventInfo.coordinates[0], eventInfo.coordinates[1]);}});
SelectionChangeEventInfo
- Since
- ArcGIS Maps SDK for JavaScript 5.0
This information is returned as toolEventInfo parameter for the Sketch.@update
event while the user is selecting or deselecting graphics using Shift+Left-click.
- Example
- // listen to update eventsketch.on("update", function(event) {const eventInfo = event.toolEventInfo;// check if a graphic is being selected or deselected.if (eventInfo && eventInfo.type === "selection-change") {if(eventInfo.added.length > 0) {// graphic is being added to the currently selected graphics.console.log("geometry type added: ", eventInfo.added[0].geometry.type);} else {// graphic is being removed from the currently selected graphics.console.log("geometry type removed: ", eventInfo.removed[0].geometry.type);}}});
DeleteEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Detailed information returned within the delete event.
graphics
- Type
- Graphic[]
- Since
- ArcGIS Maps SDK for JavaScript 5.0
An array of deleted graphics.
tool
- Type
- UpdateTool
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Name of the tool that was active when graphics are deleted.
DuplicateEvent
- Since
- ArcGIS Maps SDK for JavaScript 5.1
Detailed information returned within the duplicate event.
CustomToolOptions
- Since
- ArcGIS Maps SDK for JavaScript 5.0
public
icon
- Type
- string
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The string value indicating the Calcite icon displayed for the custom tool.
label
- Type
- string
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The text displayed in the tooltip for the custom tool.
toolKey
- Type
- string
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The unique identifier string for this custom tool. Value must not overlap with sketch create tool names.
toolName
- Type
- CreateTool
- Since
- ArcGIS Maps SDK for JavaScript 5.0
The specific sketch create tool to use for the custom tool.
createOptions
- Type
- CreateOptions | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Specific options for the create tool being used by the custom tool.
ActionProperties
- Since
- ArcGIS Maps SDK for JavaScript 5.0
afterCreate
- Type
- (el: HTMLElement) => void | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Optional callback called with the HTML element for the action after it is first rendered.
afterRemoved
- Type
- (el: HTMLElement) => void | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Optional callback called with the HTML element for the calcite-action after it is removed.
afterUpdate
- Type
- (el: HTMLElement) => void | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Optional callback called with the HTML element for the calcite-action after it is re-rendered with changes.
CustomActionProperties
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Defines the configuration for creating custom actions in Sketch.
- Supertypes
- ActionProperties
position
- Type
- "before-selection-set" | "after-selection-set" | "selection-toolbar" | "settings-before" | "settings-after"
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Controls the placement of the custom action in Sketch.