Skip to content

Sketch

ESM:
Use dark colors for code blocksCopy
1
import "@arcgis/map-components/components/arcgis-sketch";
CDN:
No specific import is needed for this component.
Since:ArcGIS Maps SDK for JavaScript 4.28

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

Demo

Properties

PropertyAttributeType
activeTool
readonlyreflected
active-tool"circle" | "custom-selection" | "freehandPolygon" | "freehandPolyline" | "lasso-selection" | "mesh" | "move" | "multipoint" | "point" | "polygon" | "polyline" | "rectangle" | "rectangle-selection" | "reshape" | "text" | "transform"
autoDestroyDisabledauto-destroy-disabledboolean
availableCreateToolsArray<"circle" | "point" | "polygon" | "rectangle" | "text" | "multipoint" | "polyline" | "mesh" | "freehandPolyline" | "freehandPolygon">
Graphic
creationModecreation-mode"continuous" | "single" | "update"
defaultCreateOptionsSketchDefaultCreateOptions
defaultGraphicsLayerDisableddefault-graphics-layer-disabledboolean
defaultUpdateOptionsSketchDefaultUpdateOptions
hideCreateToolsCirclehide-create-tools-circleboolean
hideCreateToolsMultipointhide-create-tools-multipointboolean
hideCreateToolsPointhide-create-tools-pointboolean
hideCreateToolsPolygonhide-create-tools-polygonboolean
hideCreateToolsPolylinehide-create-tools-polylineboolean
hideCreateToolsRectanglehide-create-tools-rectangleboolean
hideDeleteButtonhide-delete-buttonboolean
hideDuplicateButtonhide-duplicate-buttonboolean
hideLabelsTogglehide-labels-toggleboolean
hideSelectionCountLabelhide-selection-count-labelboolean
hideSelectionToolsLassoSelectionhide-selection-tools-lasso-selectionboolean
hideSelectionToolsRectangleSelectionhide-selection-tools-rectangle-selectionboolean
hideSettingsMenuhide-settings-menuboolean
hideSnappingControlshide-snapping-controlsboolean
hideSnappingControlsElementsEnabledTogglehide-snapping-controls-elements-enabled-toggleboolean
hideSnappingControlsElementsFeatureEnabledTogglehide-snapping-controls-elements-feature-enabled-toggleboolean
hideSnappingControlsElementsLayerListhide-snapping-controls-elements-layer-listboolean
hideSnappingControlsElementsSelfEnabledTogglehide-snapping-controls-elements-self-enabled-toggleboolean
hideTooltipsTogglehide-tooltips-toggleboolean
hideUndoRedoMenuhide-undo-redo-menuboolean
iconiconstring
labellabelstring
labelOptionsSketchLabelOptions
layerGraphicsLayer | MapNotesLayer
layoutlayout"horizontal" | "vertical"
pointSymbolCIMSymbol | PictureMarkerSymbol | PointSymbol3D | SimpleMarkerSymbol | TextSymbol | WebStyleSymbol
polygonSymbolCIMSymbol | PolygonSymbol3D | SimpleFillSymbol
polylineSymbolCIMSymbol | LineSymbol3D | SimpleLineSymbol
position
deprecated
position"bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
referenceElementreference-elementHTMLArcgisLinkChartElement | HTMLArcgisMapElement | HTMLArcgisSceneElement | string
scalescale"l" | "m" | "s"
showCreateToolsFreehandPolygonshow-create-tools-freehand-polygonboolean
showCreateToolsFreehandPolylineshow-create-tools-freehand-polylineboolean
showSnappingControlsElementsHeadershow-snapping-controls-elements-headerboolean
snappingOptionsSnappingOptions
state
readonlyreflected
state"active" | "disabled" | "ready"
toolbarKindtoolbar-kind"docked" | "floating"
tooltipOptionsSketchTooltipOptions
Collection<Graphic>
viewMapView | SceneView

activeTool

readonlyreflected
Property
activeTool: "circle" | "custom-selection" | "freehandPolygon" | "freehandPolyline" | "lasso-selection" | "mesh" | "move" | "multipoint" | "point" | "polygon" | "polyline" | "rectangle" | "rectangle-selection" | "reshape" | "text" | "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<"circle" | "point" | "polygon" | "rectangle" | "text" | "multipoint" | "polyline" | "mesh" | "freehandPolyline" | "freehandPolygon">

Property controlling the visibility and order of create tool buttons. Create tool buttons will only be rendered if they are in this collections and the matching hide/show property or attribute is configured to show the tool.

Default value
["point", "polyline", "freehandPolyline", "polygon", "freehandPolygon", "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.

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

hideCreateToolsMultipoint

Property
hideCreateToolsMultipoint: boolean

Indicates whether to display the multipoint tool. Regardless of setting, multipoint is not available when working with a scene view.

The multipoint tool is excluded from availableCreateTools by default. Even if this property is false, multipoint will not be available until it is added to availableCreateTools.

Attribute
hide-create-tools-multipoint
Default value
true

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).

See also
Attribute
icon
Default value
"pencil"

label

Property
label: string

The Sketch widget's default label.

Read more...

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.

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

deprecatedProperty
position: "bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
Deprecatedsince 4.34, use slot instead.
Attribute
position

referenceElement

Property

By assigning the id attribute of the Map or Scene component to this property, you can position a child component anywhere in the DOM while still maintaining a connection to the Map or Scene.

See also
Attribute
reference-element

scale

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

Determines the size of widget elements.

Attribute
scale
Default value
"m"

showCreateToolsFreehandPolygon

Property
showCreateToolsFreehandPolygon: boolean
Attribute
show-create-tools-freehand-polygon
Default value
false

showCreateToolsFreehandPolyline

Property
showCreateToolsFreehandPolyline: boolean
Attribute
show-create-tools-freehand-polyline
Default value
false

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
Property
state: "active" | "disabled" | "ready"

The current state of the component.

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.

Set this to docked for use within the Expand component, or any other situation where Sketch is not floating within a large canvas.

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...

view

Property

The view associated with the component.

Note: The recommended approach is to fully migrate applications to use map and scene components and avoid using MapView and SceneView directly. However, if you are migrating a large application from widgets to components, you might prefer a more gradual transition. To support this use case, the SDK includes this view property which connects a component to a MapView or SceneView. Ultimately, once migration is complete, the Sketch component will be associated with a map or scene component rather than using the view property.

Methods

MethodSignature
cancelcancel(): Promise<void>
completecomplete(): Promise<void>
componentOnReadycomponentOnReady(): Promise<void>
createcreate(tool: "circle" | "freehandPolygon" | "freehandPolyline" | "multipoint" | "point" | "polygon" | "polyline" | "rectangle", createOptions?: __esri.SketchViewModelCreateCreateOptions): Promise<void>
deletedelete(): Promise<void>
destroydestroy(): Promise<void>
duplicateduplicate(): Promise<void>
redoredo(): Promise<void>
triggerUpdatetriggerUpdate(graphic: __esri.Graphic | __esri.Graphic[], updateOptions?: __esri.SketchViewModelUpdateUpdateOptions): Promise<void>
undoundo(): 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.

Example
Use dark colors for code blocksCopy
1
2
3
4
const arcgisSketch = document.querySelector("arcgis-sketch");
document.body.append(arcgisSketch);
await arcgisSketch.componentOnReady();
console.log("arcgis-sketch is ready to go!");
Returns
Promise<void>

create

Method
create(tool: "circle" | "freehandPolygon" | "freehandPolyline" | "multipoint" | "point" | "polygon" | "polyline" | "rectangle", createOptions?: __esri.SketchViewModelCreateCreateOptions): Promise<void>
Parameters
ParameterTypeOptional?
tool"circle" | "freehandPolygon" | "freehandPolyline" | "multipoint" | "point" | "polygon" | "polyline" | "rectangle"
createOptionsSketchViewModelCreateCreateOptions | 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?
graphicArray<[Graphic](https://next.gha.afd.arcgis.com/javascript/latest/api-reference/esri-Graphic.html)> | Graphic
updateOptionsSketchViewModelUpdateUpdateOptions | undefined
Returns
Promise<void>

undo

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

Events

EventType
arcgisCreateCustomEvent<SketchCreateEvent>
arcgisDeleteCustomEvent<SketchDeleteEvent>
arcgisPropertyChangeCustomEvent<{ name: "state"; }>
arcgisReadyCustomEvent<void>
arcgisRedoCustomEvent<SketchRedoEvent>
arcgisUndoCustomEvent<SketchUndoEvent>
arcgisUpdateCustomEvent<SketchUpdateEvent>

arcgisCreate

Event
arcgisCreate: CustomEvent<SketchCreateEvent>
bubbles
composed
cancelable

arcgisDelete

Event
arcgisDelete: CustomEvent<SketchDeleteEvent>
bubbles
composed
cancelable

arcgisPropertyChange

Event
arcgisPropertyChange: CustomEvent<{ name: "state"; }>

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

bubbles
composed
cancelable

arcgisReady

Event
arcgisReady: CustomEvent<void>

Emitted when the component associated with a map or scene view is ready to be interacted with.

bubbles
composed
cancelable

arcgisRedo

Event
arcgisRedo: CustomEvent<SketchRedoEvent>
bubbles
composed
cancelable

arcgisUndo

Event
arcgisUndo: CustomEvent<SketchUndoEvent>
bubbles
composed
cancelable

arcgisUpdate

Event
arcgisUpdate: CustomEvent<SketchUpdateEvent>
bubbles
composed
cancelable

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