Sketch

Use dark colors for code blocksCopy
1
import "@arcgis/map-components/components/arcgis-sketch";

Sketch component provides a simple UI for creating and updating graphics on a MapView or a SceneView.

Demo

Properties

PropertyAttributeType
activeTool
readonly
active-tool
"circle" | "custom-selection" | "freehandPolygon" | "freehandPolyline" | "lasso-selection" | "mesh" | "move" | "multipoint" | "point" | "polygon" | "polyline" | "rectangle" | "rectangle-selection" | "reshape" | "transform"
auto-destroy-disabled
boolean
Array<"point" | "multipoint" | "polygon" | "polyline" | "mesh" | "rectangle" | "circle" | "freehandPolyline" | "freehandPolygon">
creation-mode
"continuous" | "single" | "update"
SketchDefaultCreateOptions
default-graphics-layer-disabled
boolean
SketchDefaultUpdateOptions
hide-create-tools-circle
boolean
hide-create-tools-point
boolean
hide-create-tools-polygon
boolean
hide-create-tools-polyline
boolean
hide-create-tools-rectangle
boolean
hide-delete-button
boolean
hide-duplicate-button
boolean
hide-labels-toggle
boolean
hide-selection-count-label
boolean
hide-selection-tools-lasso-selection
boolean
hide-selection-tools-rectangle-selection
boolean
hide-settings-menu
boolean
hide-snapping-controls
boolean
hide-snapping-controls-elements-enabled-toggle
boolean
hide-snapping-controls-elements-feature-enabled-toggle
boolean
hide-snapping-controls-elements-layer-list
boolean
hide-snapping-controls-elements-self-enabled-toggle
boolean
hide-tooltips-toggle
boolean
hide-undo-redo-menu
boolean
icon
string
label
string
layout
"horizontal" | "vertical"
position
"bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
reference-element
ArcgisLinkChart | ArcgisMap | ArcgisScene | string
scale
"l" | "m" | "s"
show-snapping-controls-elements-header
boolean
state
readonly
state
"active" | "disabled" | "ready"
toolbar-kind
"docked" | "floating"

activeTool

readonlyreflected

Attribute changes are reflected on the DOM.

Property
activeTool: "circle" | "custom-selection" | "freehandPolygon" | "freehandPolyline" | "lasso-selection" | "mesh" | "move" | "multipoint" | "point" | "polygon" | "polyline" | "rectangle" | "rectangle-selection" | "reshape" | "transform"

When creating new graphics (for example after create() has been called), this property reflects the create tool being used.

Read more...

Attribute
active-tool

autoDestroyDisabled

Property
autoDestroyDisabled: boolean

If true, the component will not be destroyed automatically when it is disconnected from the document. This is useful when you want to move the component to a different place on the page, or temporarily hide it. If this is set, make sure to call the `destroy` method when you are done to prevent memory leaks.

Attribute
auto-destroy-disabled
Default value
false

availableCreateTools

Property
availableCreateTools: Array<"point" | "multipoint" | "polygon" | "polyline" | "mesh" | "rectangle" | "circle" | "freehandPolyline" | "freehandPolygon">

Property controlling the visibility and order of create tool buttons.

Read more...

Default value
["point", "polyline", "polygon", "rectangle", "circle"]

createGraphic

readonlyProperty
createGraphic: Graphic

The graphic that is being created.

Read more...

creationMode

Property
creationMode: "continuous" | "single" | "update"

Defines the default behavior once the create operation is completed.

Read more...

Attribute
creation-mode
Default value
"continuous"

defaultCreateOptions

Property
defaultCreateOptions: SketchDefaultCreateOptions

Default create options set for the Sketch widget.

Read more...

defaultGraphicsLayerDisabled

Property
defaultGraphicsLayerDisabled: boolean

By default, sketch will auto-create a new graphics layer if none was provided. Set this prop to true to disable this behavior.

Attribute
default-graphics-layer-disabled
Default value
false

defaultUpdateOptions

Property
defaultUpdateOptions: SketchDefaultUpdateOptions

Default update options set for the Sketch widget.

Read more...

hideCreateToolsCircle

Property
hideCreateToolsCircle: boolean
Attribute
hide-create-tools-circle
Default value
false

hideCreateToolsPoint

Property
hideCreateToolsPoint: boolean
Attribute
hide-create-tools-point
Default value
false

hideCreateToolsPolygon

Property
hideCreateToolsPolygon: boolean
Attribute
hide-create-tools-polygon
Default value
false

hideCreateToolsPolyline

Property
hideCreateToolsPolyline: boolean
Attribute
hide-create-tools-polyline
Default value
false

hideCreateToolsRectangle

Property
hideCreateToolsRectangle: boolean
Attribute
hide-create-tools-rectangle
Default value
false

hideDeleteButton

Property
hideDeleteButton: boolean
Attribute
hide-delete-button
Default value
false

hideDuplicateButton

Property
hideDuplicateButton: boolean
Attribute
hide-duplicate-button
Default value
false

hideLabelsToggle

Property
hideLabelsToggle: boolean
Attribute
hide-labels-toggle
Default value
false

hideSelectionCountLabel

Property
hideSelectionCountLabel: boolean
Attribute
hide-selection-count-label
Default value
false

hideSelectionToolsLassoSelection

Property
hideSelectionToolsLassoSelection: boolean
Attribute
hide-selection-tools-lasso-selection
Default value
false

hideSelectionToolsRectangleSelection

Property
hideSelectionToolsRectangleSelection: boolean
Attribute
hide-selection-tools-rectangle-selection
Default value
false

hideSettingsMenu

Property
hideSettingsMenu: boolean
Attribute
hide-settings-menu
Default value
false

hideSnappingControls

Property
hideSnappingControls: boolean
Attribute
hide-snapping-controls
Default value
false

hideSnappingControlsElementsEnabledToggle

Property
hideSnappingControlsElementsEnabledToggle: boolean
Attribute
hide-snapping-controls-elements-enabled-toggle
Default value
false

hideSnappingControlsElementsFeatureEnabledToggle

Property
hideSnappingControlsElementsFeatureEnabledToggle: boolean
Attribute
hide-snapping-controls-elements-feature-enabled-toggle
Default value
false

hideSnappingControlsElementsLayerList

Property
hideSnappingControlsElementsLayerList: boolean
Attribute
hide-snapping-controls-elements-layer-list
Default value
false

hideSnappingControlsElementsSelfEnabledToggle

Property
hideSnappingControlsElementsSelfEnabledToggle: boolean
Attribute
hide-snapping-controls-elements-self-enabled-toggle
Default value
false

hideTooltipsToggle

Property
hideTooltipsToggle: boolean
Attribute
hide-tooltips-toggle
Default value
false

hideUndoRedoMenu

Property
hideUndoRedoMenu: boolean
Attribute
hide-undo-redo-menu
Default value
false

icon

Property
icon: string

Icon which represents the component. Typically used when the component is controlled by another component (e.g. by the Expand component). Search Calcite Icons for possible values.

Attribute
icon
Default value
"pencil"

label

Property
label: string

The component's default label.

Attribute
label

labelOptions

Property
labelOptions: SketchLabelOptions

Options to configure the sketch labels shown next to each segment of the geometry being created or updated.

Read more...

layer

Property

The GraphicsLayer associated with the Sketch widget.

Read more...

layout

Property
layout: "horizontal" | "vertical"

Determines the layout/orientation of the Sketch widget.

Read more...

Attribute
layout
Default value
"horizontal"

pointSymbol

Property

A SimpleMarkerSymbol, PointSymbol3D, TextSymbol, CIMSymbol, or WebStyleSymbol used for representing the point geometry that is being drawn.

Read more...

polygonSymbol

Property

A SimpleFillSymbol, PolygonSymbol3D, or CIMSymbol used for representing the polygon geometry that is being drawn.

Read more...

polylineSymbol

Property

A SimpleLineSymbol, LineSymbol3D, or CIMSymbol used for representing the polyline geometry that is being drawn.

Read more...

position

Property
position: "bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
Attribute
position
Default value
"bottom-left"

referenceElement

Property
referenceElement: ArcgisLinkChart | ArcgisMap | ArcgisScene | string
Attribute
reference-element

scale

Property
scale: "l" | "m" | "s"

Determines the size of widget elements.

Read more...

Attribute
scale
Default value
"m"

showSnappingControlsElementsHeader

Property
showSnappingControlsElementsHeader: boolean
Attribute
show-snapping-controls-elements-header
Default value
false

snappingOptions

Property
snappingOptions: SnappingOptions

The SnappingOptions for sketching.

Read more...

state

readonlyreflected

Attribute changes are reflected on the DOM.

Property
state: "active" | "disabled" | "ready"

The Sketch widget's state.

Read more...

Attribute
state

toolbarKind

Property
toolbarKind: "docked" | "floating"

Controls the appearance of the sketch widget, allowing the toolbar to adapt its appearance appropriately based on context.

Read more...

Attribute
toolbar-kind
Default value
"floating"

tooltipOptions

Property
tooltipOptions: SketchTooltipOptions

Options to configure the tooltip shown next to the cursor when creating or updating graphics.

Read more...

updateGraphics

readonlyProperty
updateGraphics: Collection<Graphic>

An array of graphics that are being updated by the Sketch widget.

Read more...

Methods

MethodSignature
cancel(): Promise<void>
complete(): Promise<void>
componentOnReady(): Promise<void>
create(tool: "circle" | "point" | "polygon" | "polyline" | "rectangle", createOptions?: __esri.SketchViewModelCreateCreateOptions): Promise<void>
delete(): Promise<void>
destroy(): Promise<void>
duplicate(): Promise<void>
redo(): Promise<void>
triggerUpdate(graphic: __esri.Graphic | __esri.Graphic[], updateOptions?: __esri.SketchViewModelUpdateUpdateOptions): Promise<void>
undo(): Promise<void>

cancel

Method
cancel(): Promise<void>
Returns
Promise<void>

complete

Method
complete(): Promise<void>
Returns
Promise<void>

componentOnReady

Method
componentOnReady(): Promise<void>

Create a promise that resolves once component is fully loaded.

Returns
Promise<void>

create

Method
create(tool: "circle" | "point" | "polygon" | "polyline" | "rectangle", createOptions?: __esri.SketchViewModelCreateCreateOptions): Promise<void>
Parameters
ParameterTypeOptional?
tool
"circle" | "point" | "polygon" | "polyline" | "rectangle"
createOptions
SketchViewModelCreateCreateOptions | undefined
Returns
Promise<void>

delete

Method
delete(): Promise<void>
Returns
Promise<void>

destroy

Method
destroy(): Promise<void>

Permanently destroy the component

Returns
Promise<void>

duplicate

Method
duplicate(): Promise<void>
Returns
Promise<void>

redo

Method
redo(): Promise<void>
Returns
Promise<void>

triggerUpdate

Method
triggerUpdate(graphic: __esri.Graphic | __esri.Graphic[], updateOptions?: __esri.SketchViewModelUpdateUpdateOptions): Promise<void>
Parameters
ParameterTypeOptional?
graphic
Array<[Graphic](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#aggregateGeometries)> | Graphic
updateOptions
SketchViewModelUpdateUpdateOptions | undefined
Returns
Promise<void>

undo

Method
undo(): Promise<void>
Returns
Promise<void>

Events

EventType
SketchCreateEvent
SketchDeleteEvent
{ name: "state"; }
undefined
SketchRedoEvent
SketchUndoEvent
SketchUpdateEvent

arcgisCreate

Event
arcgisCreate: SketchCreateEvent
bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

arcgisDelete

Event
arcgisDelete: SketchDeleteEvent
bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

arcgisPropertyChange

Event
arcgisPropertyChange: { name: "state"; }

Fired when the value of a property is changed. Use this to listen to changes to properties.

bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

arcgisReady

Event
arcgisReady: undefined
bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

arcgisRedo

Event
arcgisRedo: SketchRedoEvent
bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

arcgisUndo

Event
arcgisUndo: SketchUndoEvent
bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

arcgisUpdate

Event
arcgisUpdate: SketchUpdateEvent
bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.