Edit features with the Editor widget
This sample demonstrates how to add the Editor widget to a web application. Support for batch feature creation was added at version 4.23. Once the widget loads, click on the template to add and draw the feature's geometry. Once the feature sketch is complete, update any necessary attribute information. If wanting to create more than one feature at a time, just continue adding new geometries while updating their associated attributes. Once all feature creates are added, click Create
and any feature creates will be applied back to the feature service.
In addition to continuous feature creation, the widget's UI was also updated to automatically include snapping as it is no longer necessary to manually add the SnappingControls widget to the Editor via the API.
For additional information on these Editor updates and any limitations, please refer to the Editor API reference documentation.
How it works
Instantiate the layers and specify their LayerInfos
The application loads a webmap and iterates through all of its layers and instantiates each.
After layers are set, each layer's layerInfo is set. This takes the layer and a form template with an array of field elements. These field elements specify what values should be updated by the Editor
.
Instantiate the Editor
Based on the editing functionality set on a feature layer, you can select an existing feature to update or create new feature(s). The widget will take whatever editing capabilities are set on the service.
It is possible to override some of these capabilities by setting specific properties within the widget's layerInfos. Properties such as allowAttachments
, enabled
, updateEnabled
, and/or deleteEnabled
can be specified to further constrain how much editing can be done per layer.
It is not possible to override read-only permissions set on the server. For example, if a feature service is set up to restrict edits on a layer, it is not possible to override these restrictions via the API.
The Editor
uses the same coding pattern as other widgets, i.e. you must specify the view to be used by the widget.
Lastly, we add the widget to the application using the View's UI.
For a more advanced sample, see Editor widget with configurations and for editing in 3D see the sample Edit features in 3D with the Editor widget.