Skip to content
import EditorViewModel from "@arcgis/core/widgets/Editor/EditorViewModel.js";
Inheritance:
EditorViewModelAccessor
Example
const editor = new Editor({
viewModel: { // autocasts as new EditorViewModel
layerInfos: [{
layer: featureLayer,
deleteEnabled: false // disables deleting features
}]
}
});

Constructors

Constructor

Constructor
Parameters
ParameterTypeDescriptionRequired
properties
See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

activeWorkflow

readonly Property
Type
CreateFeaturesWorkflow | UpdateWorkflow | null | undefined

A property indicating the current active workflow. This is either CreateFeaturesWorkflow, UpdateWorkflow, or UpdateFeaturesWorkflow.

See also

attachmentsViewModel

autocast Property
Type
AttachmentsViewModel

The [AttachmentsViewModel]AttachmentsViewModel for supporting the editor widget. Attachment editing is enabled by default if the layer has support for it.

canCreate

readonly Property
Type
boolean

Convenience property that indicates at least one layer supports a create-features workflow.

canUpdate

readonly Property
Type
boolean

Convenience property that indicates at least one layer supports a update workflow. This includes the ability to delete features and modify attachments and/or related records.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor

The name of the class. The declared class name is formatted as esri.folder.className.

editorItems

readonly Property
Type
Collection<EditorItem>
Since
ArcGIS Maps SDK for JavaScript 4.29

A predominantly read-only collection of editor items that corresponds to the feature being updated.

failures

readonly Property
Type
FailedOperation[]

An array of objects containing information specific to any failed editing operations. In addition to the error(s), options to retry() or cancel() are provided.

featureFormViewModel

readonly Property
Type
FeatureFormViewModel | null | undefined

The [FeatureFormViewModel]FeatureFormViewModel for supporting the editor widget.

featureTemplatesViewModel

autocast Property
Type
FeatureTemplatesViewModel

The [FeatureTemplatesViewModel]FeatureTemplatesViewModel for supporting the editor widget.

formViewModel

readonly Property
Type
BatchAttributeFormViewModel | FeatureFormViewModel | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.33

The form's view model used to support the Editor widget. This can be either the [BatchAttributeFormViewModel]BatchAttributeFormViewModel or the [FeatureFormViewModel]FeatureFormViewModel and is dependent on the active workflow.

isUsingLegacyCreateTools

deprecatedreadonly Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 5.0

Use this property to determine if the next generation geometry creation has been disabled. This can happen when useLegacyCreateTools is true, or Editor is used with a non-2D (arcgis-map) view.

labelOptions

autocast Property
Type
SketchLabelOptions
Since
ArcGIS Maps SDK for JavaScript 4.24

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

Known Limitation

Sketch labels are currently only supported when working with a SceneView.

layerInfos

Property
Type
LayerInfo[] | null | undefined

An array of editing configurations for individual layers.

For example, if you have an editable feature layer but do not want the end user to do any type of editing, you can limit this by setting the enabled property to false.

Example
const editorViewModel = new EditorViewModel({
layerInfos: [{
layer: featureLayer, // pass in the feature layer,
formTemplate: { // autocasts to FormTemplate
elements: [
{ // autocasts to FieldElement
type: "field",
fieldName: "fulladdr",
label: "Full Address"
}
]
},
enabled: true, // default is true, set to false to disable editing functionality
addEnabled: true, // default is true, set to false to disable the ability to add a new feature
updateEnabled: false // default is true, set to false to disable the ability to edit an existing feature
deleteEnabled: false // default is true, set to false to disable the ability to delete features
}]
});

selectionManager

Property
Type
SelectionManager | null | undefined
Since
ArcGIS Maps SDK for JavaScript 5.0
beta

Use this property to supply a custom selection manager that overrides the default selection manager. This property is ignored if syncViewSelection is true. This is useful when applications want to share selection sets between components, without relying on the view's selection manager.

sketchViewModel

readonly Property
Type
SketchViewModel | null | undefined

The [SketchViewModel]SketchViewModel for supporting the editor widget.

snappingOptions

autocast Property
Type
SnappingOptions
Since
ArcGIS Maps SDK for JavaScript 4.19

The SnappingOptions for sketching. It supports self and feature snapping.

state

readonly Property
Type
State

The widget's state. Possible values are in the table below.

ValueDescription
readyDependencies are met and has valid property values.
disabledDependencies are missing and cannot provide valid inputs.
editing-existing-featureThe Editor is currently editing an existing feature.
awaiting-update-feature-candidateThe period when the application is awaiting the user's input after clicking update and multiple features are returned. Specify the feature to update.
awaiting-feature-creation-infoThis is the first step in the create-features workflow. A CreationInfo is required.
awaiting-feature-to-updateThis is the first step in the update workflow. A feature is required.
awaiting-feature-to-createThe waiting period for when a feature is created before attribute/geometry edits can be performed.
adding-attachmentIf currently editing-existing-feature and adding an attachment to an existing feature.
editing-attachmentIf currently editing-existing-feature and updating an existing attachment to an existing feature.
creating-featuresThe Editor is currently creating multiple features.
viewing-selection-listThe Editor is displaying its selection list and not editing any features.

syncing

readonly Property
Type
boolean

Indicates if there is at least one edit request being processed.

syncViewSelection

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 5.0
beta

Indicates whether the Editor should sync with the view's selection manager. Enabling this does not automatically inherit the selection sources from the SelectionManager, (e.g. which layers or graphics collections the view listens to for selections). If you need specific selection sources, configure them separately via SelectionManager.sources.

Setting this property takes precedence over the selectionManager property.

Default value
false

tooltipOptions

autocast Property
Type
SketchTooltipOptions
Since
ArcGIS Maps SDK for JavaScript 4.24

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

useLegacyCreateTools

deprecated Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 5.0

Starting at version 5.0, Editor is transitioning to a next generation geometry creation experience. This new experience provides advanced curve creation tools and allows multiple tools to be used in combination to define a single geometry.

As of 5.0, this experience is only available in 2D (e.g., MapView, arcgis-map).

This property is available to allow 2D applications to temporarily opt out of this experience.

This option will be removed in an upcoming release.

valueOptions

autocast Property
Type
SketchValueOptions
Since
ArcGIS Maps SDK for JavaScript 4.29

Options to configure how values are displayed and input when creating or updating graphics.

view

Property
Type
MapViewOrSceneView | null | undefined

A reference to the MapView or SceneView. This view provides the editable layers for the Editor widget and is required when instantiating the widget.

Methods

MethodSignatureClass
cancelSelectionTool(): void
cancelWorkflow(): Promise<void>
deleteAssociationFromWorkflow(): Promise<void>
deleteFeatureFromWorkflow(): Promise<void>
deleteFeatures(): Promise<void>
emit
inherited
emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
getTemplatesForLayer(layer: EditorLayerUnion): (FeatureTemplate | SharedTemplateMetadata)[]
hasEventListener
inherited
hasEventListener<Type extends EventNames<this>>(type: Type): boolean
on
inherited
on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
startCreateFeaturesWorkflowAtFeatureCreation(creationInfo: Required<Pick<CreationInfo, "layer" | "template">>): Promise<void>
startCreateFeaturesWorkflowAtFeatureEdit(params: EditorViewModelStartCreateFeaturesWorkflowAtFeatureEditParameters): Promise<void>
startCreateFeaturesWorkflowAtFeatureTypeSelection(): Promise<void>
startMergeFeaturesWorkflow(features: Graphic[] | FeatureInfo, options?: EditorViewModelStartMergeFeaturesWorkflowOptions): Promise<void>
startSplitFeatureWorkflow(feature: Graphic, options?: EditorViewModelStartSplitFeatureWorkflowOptions): Promise<void>
startUpdateFeaturesWorkflow(features: Graphic[] | FeatureInfo): Promise<void>
startUpdateWorkflowAtFeatureEdit(feature: Graphic): Promise<void>
startUpdateWorkflowAtFeatureSelection(): Promise<void>
startUpdateWorkflowAtMultipleFeatureSelection(candidates: Graphic[]): Promise<void>
toggleUpdateWorkflow(): Promise<void>

cancelSelectionTool

Method
Signature
cancelSelectionTool (): void
Since
ArcGIS Maps SDK for JavaScript 5.0

Cancels any active selection operation.

Returns
void

cancelWorkflow

Method
Signature
cancelWorkflow (): Promise<void>

Cancels any active workflow.

Returns
Promise<void>

Resolves once the workflow is canceled.

deleteAssociationFromWorkflow

Method
Signature
deleteAssociationFromWorkflow (): Promise<void>

This is applicable if there is an active update workflow with an active child workflow. This method deletes the utility network association involved with the active child workflow's feature.

See also
Returns
Promise<void>

Resolves once the active UpdateWorkflow is deleted.

deleteFeatureFromWorkflow

deprecated Method
Signature
deleteFeatureFromWorkflow (): Promise<void>

This is applicable if there is an active update workflow with an active child workflow. In this case, this method deletes the feature associated with the active child workflow.

See also
Returns
Promise<void>

Resolves once the active UpdateWorkflow is deleted.

deleteFeatures

Method
Signature
deleteFeatures (): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.33

If the active workflow is an UpdateWorkflow or UpdateFeaturesWorkflow, this method deletes the feature(s) associated with the workflow.

See also
Returns
Promise<void>

Resolves once the features have been deleted.

emit

inherited Method
Signature
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Emits an event on the instance. This method should only be used when creating subclasses of this class.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

event
this["@eventTypes"][Type]

The event payload.

Returns
boolean

true if a listener was notified

getTemplatesForLayer

Method
Signature
getTemplatesForLayer (layer: EditorLayerUnion): (FeatureTemplate | SharedTemplateMetadata)[]
Since
ArcGIS Maps SDK for JavaScript 4.32

Get all of the editing templates associated with a given layer. The items in the resulting array will be SharedTemplateMetadata objects if there are any shared templates defined for the layer; otherwise, they will be standard FeatureTemplate objects.

Parameters
ParameterTypeDescriptionRequired
layer

The layer whose templates should be retrieved.

Returns
(FeatureTemplate | SharedTemplateMetadata)[]

An array of templates associated with the layer.

hasEventListener

inherited Method
Signature
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Indicates whether there is an event listener on the instance that matches the provided event name.

Parameters
ParameterTypeDescriptionRequired
type
Type

The name of the event.

Returns
boolean

Returns true if the class supports the input event.

on

inherited Method
Signature
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
Type parameters
<Type extends EventNames<this>>
Inherited from: EventedMixin

Registers an event handler on the instance. Call this method to hook an event with a listener.

Parameters
ParameterTypeDescriptionRequired
type
Type

An event or an array of events to listen for.

listener
EventedCallback<this["@eventTypes"][Type]>

The function to call when the event fires.

Returns
ResourceHandle

Returns an event handler with a remove() method that should be called to stop listening for the event(s).

PropertyTypeDescription
removeFunctionWhen 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);
});

startCreateFeaturesWorkflowAtFeatureCreation

Method
Signature
startCreateFeaturesWorkflowAtFeatureCreation (creationInfo: Required<Pick<CreationInfo, "layer" | "template">>): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.23

Initiates the CreateFeaturesWorkflow by displaying the panel where feature creation begins. This method takes a CreateFeaturesCreationInfo object containing the layer(s) and template(s) to use.

Parameters
ParameterTypeDescriptionRequired
creationInfo
Required<Pick<CreationInfo, "layer" | "template">>

An object containing information needed to create a new feature using the Editor widget. This object provides the feature template and layer for creating a new feature.

Returns
Promise<void>

Resolves when the CreateFeaturesWorkflow initiates and displays the panel where feature creation begins.

startCreateFeaturesWorkflowAtFeatureEdit

Method
Signature
startCreateFeaturesWorkflowAtFeatureEdit (params: EditorViewModelStartCreateFeaturesWorkflowAtFeatureEditParameters): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.28

This method starts the CreateFeaturesWorkflow at the "creating-features" step with the provided feature.

Any CreateFeaturesWorkflow instance generated by this method will only support creating a single feature per operation, (ie. batch creation is disabled).

See also
Parameters
ParameterTypeDescriptionRequired
params

Parameters object containing an initialFeature to use in the associated CreateFeaturesWorkflow.

Returns
Promise<void>

Resolves once the CreateFeaturesWorkflow initiates and displays the panel where additional edits can be made to the provided feature.

startCreateFeaturesWorkflowAtFeatureTypeSelection

Method
Signature
startCreateFeaturesWorkflowAtFeatureTypeSelection (): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.23

Initiates the CreateFeaturesWorkflow by displaying the FeatureTemplates panel.

Returns
Promise<void>

Resolves when the CreateFeaturesWorkflow is initiated and displays the FeatureTemplates panel.

startMergeFeaturesWorkflow

Method
Signature
startMergeFeaturesWorkflow (features: Graphic[] | FeatureInfo, options?: EditorViewModelStartMergeFeaturesWorkflowOptions): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.34

Starts a MergeFeaturesWorkflow for the specified features. All features must belong to the same layer.

Parameters
ParameterTypeDescriptionRequired
features

The features to be merged. These can be supplied either as an array of Graphic instances or as a single FeatureInfo object specifying a layer and the object IDs of the features.

options

Options for the merge features workflow.

Returns
Promise<void>

startSplitFeatureWorkflow

Method
Signature
startSplitFeatureWorkflow (feature: Graphic, options?: EditorViewModelStartSplitFeatureWorkflowOptions): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.34

Starts a split feature workflow for the given feature.

Parameters
ParameterTypeDescriptionRequired
feature

The feature to be split.

options

Options for the split feature workflow.

Returns
Promise<void>

Resolves once the SplitFeatureWorkflow has been initialized and is active.

startUpdateFeaturesWorkflow

Method
Signature
startUpdateFeaturesWorkflow (features: Graphic[] | FeatureInfo): Promise<void>
Since
ArcGIS Maps SDK for JavaScript 4.33

Starts an UpdateFeaturesWorkflow using the provided features.

Parameters
ParameterTypeDescriptionRequired
features

The features to be updated. These can be supplied either as an array of Graphic instances or as a single FeatureInfo object specifying a layer and the object IDs of the features.

Returns
Promise<void>

Resolves once the UpdateFeaturesWorkflow is initiated.

startUpdateWorkflowAtFeatureEdit

Method
Signature
startUpdateWorkflowAtFeatureEdit (feature: Graphic): Promise<void>

Starts the update workflow at the feature geometry and attribute editing panel.

See also
Parameters
ParameterTypeDescriptionRequired
feature

The feature to be updated.

Returns
Promise<void>

Resolves once the UpdateWorkflow initiates the feature geometry and attribute editing panel.

startUpdateWorkflowAtFeatureSelection

Method
Signature
startUpdateWorkflowAtFeatureSelection (): Promise<void>

Starts the update workflow using the current selected feature.

See also
Returns
Promise<void>

Resolves once the UpdateWorkflow is initiated using the current selected feature.

startUpdateWorkflowAtMultipleFeatureSelection

Method
Signature
startUpdateWorkflowAtMultipleFeatureSelection (candidates: Graphic[]): Promise<void>

Starts the Editor workflow where it waits for multiple features to be selected.

See also
Parameters
ParameterTypeDescriptionRequired
candidates

The selected feature candidates.

Returns
Promise<void>

Resolves once the UpdateWorkflow is initiated as it waits for multiple features to be selected.

toggleUpdateWorkflow

Method
Signature
toggleUpdateWorkflow (): Promise<void>

Toggles the UpdateWorkflow.

Returns
Promise<void>

Events

sketch-create

Event
Since
ArcGIS Maps SDK for JavaScript 4.29

Fires when a user starts drawing a feature, is actively drawing a feature, and completes drawing a feature.

bubbles composed cancelable
Example
// Listen to Editor's create event.
editor.on("sketch-create", function(evt) {
const { graphic, tool } = evt.detail;
// Check if the tool used is a 'polyline'
if (tool === "polyline") {
// Set the active polyline symbol to white while drawing
graphic.symbol.color = "#ffffff";
}
});

sketch-update

Event
Since
ArcGIS Maps SDK for JavaScript 4.29

Fires when a user starts updating a feature's geometry, is actively updating a feature's geometry, and completes updating a feature's geometry.

bubbles composed cancelable
Example
// Listen to Editor's update event.
editor.on("sketch-update", function(evt) {
const { tool, graphics } = evt.detail;
// Check if the layer's geometryType is a 'polyline'
if (evt.layer?.geometryType === "polyline") {
// For every feature, update the line symbol
// width to emphasize the feature being updated
graphics.forEach((graphic) => graphic.symbol.width = 5);
}
});

Type definitions

EditorViewModelStartCreateFeaturesWorkflowAtFeatureEditParameters

Type definition

initialFeature

Property
Type
Graphic

The initial feature used when you begin creating features.

EditorViewModelStartMergeFeaturesWorkflowOptions

Type definition

keyFeature

Property
Type
Graphic | undefined

The feature that the other features will be merged into. This feature will have its geometry updated with the merged geometry. The other features will be deleted.

EditorViewModelStartSplitFeatureWorkflowOptions

Type definition

startAt

Property
Type
SplitFeatureWorkflowStep | undefined

The step to start the workflow at.

defaultSplitterGeometryType

Property
Type
SplitterGeometryType | undefined

The preferred Sketch tool to use for drawing the splitter geometry.

splitterGeometry

Property
Type
SplitterGeometry | undefined

The geometry with which to split the input geometry. This is required in order to start the workflow at the "reviewing-features" step. Otherwise, it is ignored.