import EditorViewModel from "@arcgis/core/widgets/Editor/EditorViewModel.js";const EditorViewModel = await $arcgis.import("@arcgis/core/widgets/Editor/EditorViewModel.js");- Inheritance:
- EditorViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.11
Provides the logic for the Editor widget and component.
- See also
Editor widget
Example
const editor = new Editor({ viewModel: { // autocasts as new EditorViewModel layerInfos: [{ layer: featureLayer, deleteEnabled: false // disables deleting features }] }});Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
activeWorkflow readonly | | |
| | ||
canCreate readonly | | |
canUpdate readonly | | |
declaredClass readonly inherited | ||
editorItems readonly | | |
failures readonly | | |
featureFormViewModel readonly | | |
| | ||
formViewModel readonly | | |
isUsingLegacyCreateTools deprecated readonly | | |
| | ||
| | ||
| | ||
sketchViewModel readonly | | |
| | ||
state readonly | | |
syncing readonly | | |
| | ||
| | ||
useLegacyCreateTools deprecated | | |
| | ||
| |
activeWorkflow
- Type
- CreateFeaturesWorkflow | UpdateWorkflow | null | undefined
A property indicating the current active workflow. This is either CreateFeaturesWorkflow, UpdateWorkflow, or UpdateFeaturesWorkflow.
- See also
attachmentsViewModel
- Type
- AttachmentsViewModel
The [AttachmentsViewModel]AttachmentsViewModel for supporting the editor widget. Attachment editing is enabled by default if the layer has support for it.
canCreate
- Type
- boolean
Convenience property that indicates at least one layer supports a create-features workflow.
canUpdate
- 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.
editorItems
- 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
- 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
- Type
- FeatureFormViewModel | null | undefined
The [FeatureFormViewModel]FeatureFormViewModel for supporting the editor widget.
featureTemplatesViewModel
The [FeatureTemplatesViewModel]FeatureTemplatesViewModel for supporting the editor widget.
formViewModel
- 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
- 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
- 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
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
- Type
- SelectionManager | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 5.0
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
- Type
- SketchViewModel | null | undefined
The [SketchViewModel]SketchViewModel for supporting the editor widget.
snappingOptions
- Type
- SnappingOptions
- Since
- ArcGIS Maps SDK for JavaScript 4.19
The SnappingOptions for sketching. It supports self and feature snapping.
state
- Type
- State
The widget's state. Possible values are in the table below.
| Value | Description |
|---|---|
| ready | Dependencies are met and has valid property values. |
| disabled | Dependencies are missing and cannot provide valid inputs. |
| editing-existing-feature | The Editor is currently editing an existing feature. |
| awaiting-update-feature-candidate | The 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-info | This is the first step in the create-features workflow. A CreationInfo is required. |
| awaiting-feature-to-update | This is the first step in the update workflow. A feature is required. |
| awaiting-feature-to-create | The waiting period for when a feature is created before attribute/geometry edits can be performed. |
| adding-attachment | If currently editing-existing-feature and adding an attachment to an existing feature. |
| editing-attachment | If currently editing-existing-feature and updating an existing attachment to an existing feature. |
| creating-features | The Editor is currently creating multiple features. |
| viewing-selection-list | The Editor is displaying its selection list and not editing any features. |
syncing
- Type
- boolean
Indicates if there is at least one edit request being processed.
syncViewSelection
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 5.0
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
- 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
- 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
- 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
- Type
- MapViewOrSceneView | null | undefined
Methods
| Method | Signature | Class |
|---|---|---|
cancelSelectionTool(): void | | |
cancelWorkflow(): Promise<void> | | |
deleteAssociationFromWorkflow(): Promise<void> | | |
deleteFeatureFromWorkflow deprecated | 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
- Signature
-
cancelSelectionTool (): void
- Since
- ArcGIS Maps SDK for JavaScript 5.0
Cancels any active selection operation.
- Returns
- void
deleteAssociationFromWorkflow
- 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
- 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
- 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.
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
Emits an event on the instance. This method should only be used when creating subclasses of this class.
getTemplatesForLayer
- 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
| Parameter | Type | Description | Required |
|---|---|---|---|
| layer | The layer whose templates should be retrieved. | |
- Returns
- (FeatureTemplate | SharedTemplateMetadata)[]
An array of templates associated with the layer.
hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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).Property Type Description remove Function When 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
- 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
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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
- 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
| Parameter | Type | Description | Required |
|---|---|---|---|
| params | Parameters object containing an | |
- Returns
- Promise<void>
Resolves once the CreateFeaturesWorkflow initiates and displays the panel where additional edits can be made to the provided feature.
startCreateFeaturesWorkflowAtFeatureTypeSelection
- 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
- 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
| Parameter | Type | Description | Required |
|---|---|---|---|
| features | Graphic[] | FeatureInfo | 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. | |
startSplitFeatureWorkflow
- 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
| Parameter | Type | Description | Required |
|---|---|---|---|
| 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
- Signature
-
startUpdateFeaturesWorkflow (features: Graphic[] | FeatureInfo): Promise<void>
- Since
- ArcGIS Maps SDK for JavaScript 4.33
Starts an UpdateFeaturesWorkflow using the provided features.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| features | Graphic[] | FeatureInfo | 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
- Signature
-
startUpdateWorkflowAtFeatureEdit (feature: Graphic): Promise<void>
Starts the update workflow at the feature geometry and attribute editing panel.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| feature | The feature to be updated. | |
- Returns
- Promise<void>
Resolves once the UpdateWorkflow initiates the feature geometry and attribute editing panel.
startUpdateWorkflowAtFeatureSelection
- 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
- Signature
-
startUpdateWorkflowAtMultipleFeatureSelection (candidates: Graphic[]): Promise<void>
Starts the Editor workflow where it waits for multiple features to be selected.
- See also
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| candidates | Graphic[] | The selected feature candidates. | |
- Returns
- Promise<void>
Resolves once the UpdateWorkflow is initiated as it waits for multiple features to be selected.
Events
sketch-create
sketch-create: CustomEvent<EditorSketchCreateEvent> - 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.
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
sketch-update: CustomEvent<EditorSketchUpdateEvent> - 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.
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
EditorViewModelStartSplitFeatureWorkflowOptions
defaultSplitterGeometryType
- Type
- SplitterGeometryType | undefined
The preferred Sketch tool to use for drawing the splitter geometry.
splitterGeometry
- 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.