import EditorVM from "@arcgis/core/widgets/Editor/EditorViewModel.js";
const EditorVM = await $arcgis.import("@arcgis/core/widgets/Editor/EditorViewModel.js");
@arcgis/core/widgets/Editor/EditorViewModel
- See also
const editor = new Editor({
viewModel: { // autocasts as new EditorViewModel
layerInfos: [{
layer: featureLayer,
deleteEnabled: false // disables deleting features
}]
}
});
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
| Name | Type | Summary | Class |
|---|---|---|---|
A property indicating the current active workflow. | EditorViewModel | ||
The AttachmentsViewModel for supporting the editor widget. | EditorViewModel | ||
Convenience property that indicates at least one layer supports a | EditorViewModel | ||
Convenience property that indicates at least one layer supports a | EditorViewModel | ||
The name of the class. | Accessor | ||
A predominantly read-only collection of editor items that corresponds to the feature being updated. | EditorViewModel | ||
An array of objects containing information specific to any failed editing operations. | EditorViewModel | ||
The FeatureFormViewModel for supporting the editor widget. | EditorViewModel | ||
The FeatureTemplatesViewModel for supporting the editor widget. | EditorViewModel | ||
The form's view model used to support the Editor widget. | EditorViewModel | ||
Options to configure the labels shown next to each segment of the geometry being created or updated. | EditorViewModel | ||
An array of editing configurations for individual layers. | EditorViewModel | ||
The SketchViewModel for supporting the editor widget. | EditorViewModel | ||
The SnappingOptions for sketching. | EditorViewModel | ||
The widget's state. | EditorViewModel | ||
Indicates if there is at least one edit request being processed. | EditorViewModel | ||
Options to configure the tooltip shown next to the cursor when creating or updating graphics. | EditorViewModel | ||
Options to configure how values are displayed and input when creating or updating graphics. | EditorViewModel | ||
| EditorViewModel |
Property Details
-
activeWorkflow
PropertyactiveWorkflow CreateFeaturesWorkflow |UpdateWorkflow |UpdateFeaturesWorkflow |null |undefinedreadonly -
A property indicating the current active workflow. This is either CreateFeaturesWorkflow, UpdateWorkflow, or UpdateFeaturesWorkflow.
- See also
-
attachmentsViewModel
PropertyattachmentsViewModel AttachmentsViewModelautocast -
The AttachmentsViewModel for supporting the editor widget. Attachment editing is enabled by default if the layer has support for it.
-
canCreate
PropertycanCreate Booleanreadonly -
Convenience property that indicates at least one layer supports a
create-featuresworkflow.
-
canUpdate
PropertycanUpdate Booleanreadonly -
Convenience property that indicates at least one layer supports a
updateworkflow. This includes the ability to delete features and modify attachments and/or related records.
-
editorItems
PropertyeditorItems Collection<EditorItem>readonlySince: ArcGIS Maps SDK for JavaScript 4.29EditorViewModel since 4.11, editorItems added at 4.29. -
A predominantly read-only collection of editor items that corresponds to the feature being updated.
-
An array of objects containing information specific to any failed editing operations. In addition to the error(s), options to
retry()orcancel()are provided.- Property
-
error Error
The read-only error message.
-
featureFormViewModel
PropertyfeatureFormViewModel FeatureFormViewModel |null |undefinedreadonly -
The FeatureFormViewModel for supporting the editor widget.
-
featureTemplatesViewModel
PropertyfeatureTemplatesViewModel FeatureTemplatesViewModelautocast -
The FeatureTemplatesViewModel for supporting the editor widget.
-
formViewModel
PropertyformViewModel BatchAttributeFormViewModel |FeatureFormViewModel |null |undefinedreadonlySince: ArcGIS Maps SDK for JavaScript 4.33EditorViewModel since 4.11, formViewModel added at 4.33. -
The form's view model used to support the Editor widget. This can be either the BatchAttributeFormViewModel or the FeatureFormViewModel and is dependent on the active workflow.
-
labelOptions
PropertylabelOptions SketchLabelOptionsautocastSince: ArcGIS Maps SDK for JavaScript 4.24EditorViewModel since 4.11, labelOptions added at 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.
-
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
enabledproperty tofalse.Exampleconst 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 }] });
-
sketchViewModel
PropertysketchViewModel SketchViewModel |null |undefinedreadonly -
The SketchViewModel for supporting the editor widget.
-
snappingOptions
PropertysnappingOptions SnappingOptionsautocastSince: ArcGIS Maps SDK for JavaScript 4.19EditorViewModel since 4.11, snappingOptions added at 4.19. -
The SnappingOptions for sketching. It supports self and feature snapping.
-
state
Propertystate Stringreadonly -
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-featuresworkflow. A CreationInfo is required.awaiting-feature-to-update This is the first step in the updateworkflow. 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-featureand adding an attachment to an existing feature.editing-attachment If currently editing-existing-featureand 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. Possible Values:"add-association-create-association" |"add-association-select-feature" |"add-association-select-layer" |"adding-attachment" |"awaiting-feature-creation-info" |"awaiting-feature-to-create" |"awaiting-feature-to-update" |"awaiting-update-feature-candidate" |"choosing-key-feature" |"creating-features" |"disabled" |"drawing-splitter-geometry" |"editing-attributes" |"editing-attachment" |"editing-existing-feature" |"editing-features" |"ready" |"reviewing-features" |"viewing-selection-list"
-
syncing
Propertysyncing Booleanreadonly -
Indicates if there is at least one edit request being processed.
-
tooltipOptions
PropertytooltipOptions SketchTooltipOptionsautocastSince: ArcGIS Maps SDK for JavaScript 4.24EditorViewModel since 4.11, tooltipOptions added at 4.24. -
Options to configure the tooltip shown next to the cursor when creating or updating graphics.
-
valueOptions
PropertyvalueOptions SketchValueOptionsautocastSince: ArcGIS Maps SDK for JavaScript 4.29EditorViewModel since 4.11, valueOptions added at 4.29. -
Options to configure how values are displayed and input when creating or updating graphics.
Method Overview
| Name | Return Type | Summary | Class |
|---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
Promise<void> | Cancels any active workflow. | EditorViewModel | |
Promise<void> | This is applicable if there is an active update workflow with an active child workflow. | EditorViewModel | |
Promise<void> | This is applicable if there is an active update workflow with an active child workflow. | EditorViewModel | |
Promise<void> | If the active workflow is an UpdateWorkflow or UpdateFeaturesWorkflow, this method deletes the feature(s) associated with the workflow. | EditorViewModel | |
Get all of the editing templates associated with a given layer. | EditorViewModel | ||
Returns true if a named group of handles exist. | Accessor | ||
Removes a group of handles owned by the object. | Accessor | ||
Promise<void> | Initiates the CreateFeaturesWorkflow by displaying the panel where feature creation begins. | EditorViewModel | |
Promise<void> | This method starts the CreateFeaturesWorkflow at the "creating-features" step with the provided feature. | EditorViewModel | |
Promise<void> | Initiates the CreateFeaturesWorkflow by displaying the FeatureTemplates panel. | EditorViewModel | |
Starts a MergeFeaturesWorkflow for the specified features. | EditorViewModel | ||
Promise<void> | Starts a split feature workflow for the given feature. | EditorViewModel | |
Promise<void> | Starts an UpdateFeaturesWorkflow using the provided features. | EditorViewModel | |
Promise<void> | Starts the update workflow at the feature geometry and attribute editing panel. | EditorViewModel | |
Promise<void> | Starts the | EditorViewModel | |
Promise<void> | Starts the Editor workflow where it waits for multiple features to be selected. | EditorViewModel | |
Toggles the | EditorViewModel |
Method Details
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, addHandles added at 4.25. -
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
Cancels any active workflow.
ReturnsType Description Promise<void> Resolves once the workflow is canceled.
-
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.
ReturnsType Description Promise<void> Resolves once the active UpdateWorkflow is deleted. - See also
-
Deprecated since version 4.33. Use
deleteFeaturesinstead. -
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.
ReturnsType Description Promise<void> Resolves once the active UpdateWorkflow is deleted. - See also
-
Since: ArcGIS Maps SDK for JavaScript 4.33EditorViewModel since 4.11, deleteFeatures added at 4.33. -
If the active workflow is an UpdateWorkflow or UpdateFeaturesWorkflow, this method deletes the feature(s) associated with the workflow.
ReturnsType Description Promise<void> Resolves once the features have been deleted. - See also
-
getTemplatesForLayer
MethodgetTemplatesForLayer(layer){Array<(FeatureTemplate|SharedTemplateMetadata)>}Since: ArcGIS Maps SDK for JavaScript 4.32EditorViewModel since 4.11, getTemplatesForLayer added at 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.
ParameterThe layer whose templates should be retrieved.
ReturnsType Description Array<(FeatureTemplate|SharedTemplateMetadata)> An array of templates associated with the layer.
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns trueif a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
startCreateFeaturesWorkflowAtFeatureCreation
MethodstartCreateFeaturesWorkflowAtFeatureCreation(creationInfo){Promise<void>}Since: ArcGIS Maps SDK for JavaScript 4.23EditorViewModel since 4.11, startCreateFeaturesWorkflowAtFeatureCreation added at 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.
ParametercreationInfo CreateFeaturesCreationInfoAn 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.
ReturnsType Description Promise<void> Resolves when the CreateFeaturesWorkflow initiates and displays the panel where feature creation begins.
-
startCreateFeaturesWorkflowAtFeatureEdit
MethodstartCreateFeaturesWorkflowAtFeatureEdit(params){Promise<void>}Since: ArcGIS Maps SDK for JavaScript 4.28EditorViewModel since 4.11, startCreateFeaturesWorkflowAtFeatureEdit added at 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).
ParametersReturnsType Description Promise<void> Resolves once the CreateFeaturesWorkflow initiates and displays the panel where additional edits can be made to the provided feature. - See also
-
startCreateFeaturesWorkflowAtFeatureTypeSelection
MethodstartCreateFeaturesWorkflowAtFeatureTypeSelection(){Promise<void>}Since: ArcGIS Maps SDK for JavaScript 4.23EditorViewModel since 4.11, startCreateFeaturesWorkflowAtFeatureTypeSelection added at 4.23. -
Initiates the CreateFeaturesWorkflow by displaying the FeatureTemplates panel.
ReturnsType Description Promise<void> Resolves when the CreateFeaturesWorkflow is initiated and displays the FeatureTemplates panel.
-
Since: ArcGIS Maps SDK for JavaScript 4.34EditorViewModel since 4.11, startMergeFeaturesWorkflow added at 4.34. -
Starts a MergeFeaturesWorkflow for the specified features. All features must belong to the same layer.
Parametersfeatures Graphic[]|FeatureInfoThe 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 ObjectOptions for the merge features workflow.
SpecificationkeyFeature GraphicoptionalThe 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.
-
Since: ArcGIS Maps SDK for JavaScript 4.34EditorViewModel since 4.11, startSplitFeatureWorkflow added at 4.34. -
Starts a split feature workflow for the given feature.
ParametersSpecificationfeature GraphicThe feature to be split.
options ObjectOptions for the split feature workflow.
SpecificationdefaultSplitterGeometryType StringoptionalThe preferred Sketch tool to use for drawing the splitter geometry.
Possible Values:"point"|"polyline"|"polygon"
optional 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.
startAt StringoptionalThe step to start the workflow at.
Possible Values:"drawing-splitter-geometry"|"reviewing-features"
ReturnsType Description Promise<void> Resolves once the SplitFeatureWorkflow has been initialized and is active.
-
Since: ArcGIS Maps SDK for JavaScript 4.33EditorViewModel since 4.11, startUpdateFeaturesWorkflow added at 4.33. -
Starts an UpdateFeaturesWorkflow using the provided features.
Parameterfeatures Graphic[]|FeatureInfoThe 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.
ReturnsType Description Promise<void> Resolves once the UpdateFeaturesWorkflow is initiated.
-
Starts the update workflow at the feature geometry and attribute editing panel.
Parameterfeature GraphicThe feature to be updated.
ReturnsType Description Promise<void> Resolves once the UpdateWorkflow initiates the feature geometry and attribute editing panel. - See also
-
Starts the
updateworkflow using the current selected feature.ReturnsType Description Promise<void> Resolves once the UpdateWorkflow is initiated using the current selected feature. - See also
-
Starts the Editor workflow where it waits for multiple features to be selected.
ReturnsType Description Promise<void> Resolves once the UpdateWorkflow is initiated as it waits for multiple features to be selected. - See also
Event Overview
| Name | Type | Summary | Class |
|---|---|---|---|
|
|
{type: "sketch-create",layer: FeatureLayer|SceneLayer|SubtypeSublayer,detail: Object,detail.graphic: Graphic,detail.state: "start"|"active"|"complete"|"cancel",detail.tool: "point"|"multipoint"|"polyline"|"polygon"|"circle"|"rectangle"|"mesh",detail.toolEventInfo: CreateToolEventInfo,detail.type: "create"} |
Fires when a user starts drawing a feature, is actively drawing a feature, and completes drawing a feature. |
EditorViewModel |
|
|
{type: "sketch-update",layer: FeatureLayer|SceneLayer|SubtypeSublayer,detail: Object,detail.aborted: Boolean,detail.graphics: Graphic[],detail.state: "start"|"active"|"complete",detail.tool: "move"|"transform"|"reshape",toolEventInfo: UpdateToolEventInfo,detail.type: "update"} |
Fires when a user starts updating a feature's geometry, is actively updating a feature's geometry, and completes updating a feature's geometry. |
EditorViewModel |
Event Details
-
Since: ArcGIS Maps SDK for JavaScript 4.29EditorViewModel since 4.11, sketch-create added at 4.29. -
Fires when a user starts drawing a feature, is actively drawing a feature, and completes drawing a feature.
- Properties
-
type String
The value is always "sketch-create".
The layer currently being edited.
detail ObjectDetailed information returned within the "sketch-create" event.
- Specification
-
graphic Graphic
The feature being created.
state StringThe current state of the event.
Value Description start State changes to startwhen the first vertex is created. Not applicable when creatingpoints.active State is activewhile feature is being created. Not applicable when creatingpoints.complete State changes to completeafter the complete() method is called, when the user double clicks, presses theEnterkey or clicks the first vertex of thepolygonwhile creating a feature. Whenpointis created, the a singlesketch-createevent is fired with thecompletestate.cancel State changes to cancelif the user presses the escape key or the create() or cancel() methods are called during the create operation and before the state changes tocomplete.Possible Values:"start"|"active"|"complete"|"cancel"
tool StringName of the create tool.
Possible Values:"point"|"multipoint"|"polyline"|"polygon"|"circle"|"rectangle"|"mesh"
toolEventInfo CreateToolEventInfoReturns additional information associated with the create operation.
type StringThe value is always "create".
Example// Listen to EditorViewModel's create event. editorViewModel.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"; } });
-
Since: ArcGIS Maps SDK for JavaScript 4.29EditorViewModel since 4.11, sketch-update added at 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.
- Properties
-
type String
The value is always "sketch-update".
The layer currently being edited.
detail ObjectDetailed information returned within the "sketch-update" event.
- Specification
-
aborted Boolean
Indicates if the update operation was aborted. Returns
trueif the user pressed theesckey, or when the update(), create() or cancel() method is called before theupdateevent'sstatechanges tocomplete.An array of features that are being updated.
state StringThe state of the event.
Value Description start State changes to startwhen a feature is selected to update.active State is activewhile features are being updated andtoolEventInfoparameter is notnull.complete State changes to completeafter features are updated.Possible Values:"start"|"active"|"complete"
tool StringName of the update operation tool.
Possible Values:"move"|"transform"|"reshape"
toolEventInfo UpdateToolEventInfoUpdate operation tool info. Returns additional information associated with the update operation that is taking place for selected feature and what stage it is at. Value of this parameter changes to
nullwhen theupdateevent'sstatechanges tocomplete.detail.type StringThe value is always "update".
Example// Listen to EditorViewModel's update event. editorViewModel.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); } });