advanced-editing

This bundle adds tools to create, update and delete features.

Usage

No configuration is required! Default values are applied.

To use the features of this bundle, add one or more of the following tools to your app:

Tool ID Component Description
advancedEditingAddFeatureTool AdvancedEditingAddFeatureTool Create a new object.
advancedEditingUpdateFeatureTool AdvancedEditingUpdateFeatureTool Update an existing object.
advancedEditingMergeFeaturesTool AdvancedEditingMergeFeaturesTool Merge two existing objects.

Configuration Reference

The following sample shows the configurable properties and its default values:

{
    "advanced-editing": {
        "Config": {
            "showSketching": true,
            "allowGeometryEditing": true,
            "allowAttributeEditing": true,
            "allowAttachmentEditing": true,
            "allowMovingObject": true,
            "allowBasemapSnapping": false,
            "removeHelperGeometriesOnClose": true,
            "snappingEnabled": true,
            "snappingOptions": {
                "distance": 6,
                "selfEnabled": true,
                "featureEnabled": true
            },
            "featureTemplates": {
                "groupBy": "layer",
                "filterText": "",
                "visibleElements": {
                    "filter": true
                }
            }
        }
    }
}
Property Type Description
showSketching Boolean If set to false, the section for helper geometries is hidden.
allowGeometryEditing Boolean If set to false, the tab for geometry editing is hidden during the workflow of editing existing features.
allowAttributeEditing Boolean If set to false, the tab for attribute editing is hidden during the workflow of editing existing features.
allowAttachmentEditing Boolean If set to false, the tab for attachment editing is hidden during the workflow of editing existing features.
allowMovingObject Boolean If set to false, the object cannot be moved as a whole.
allowBasemapSnapping Boolean If set to true, basemaps are used for snapping as well.
removeHelperGeometriesOnClose Boolean If set to true, the helper geometries are removed when the editing dialog is closed.
featureTemplates Object Defines filter and group options for the template selector when adding new features.
featureTemplates.groupBy String Allowed values are layer, geometry and none.
snappingEnabled Boolean If set to true, all layers that allow snapping are snapped in the create and edit workflow. This state can also be controlled by the user in the user interface. This property deactivates snapping globally if it is set to false. It must be true so that the properties snappingOptions.selfEnabled and snappingOptions.featureEnabled have an effect.
snappingOptions.distance Number Snapping distance for snapping in pixels.
snappingOptions.selfEnabled Boolean Global configuration option to turn self snapping (snapping on the feature that is currently being drawn or edited) on or off. snappingEnabled must be true for this option to have an effect.
snappingOptions.featureEnabled Boolean Global configuration option to turn snapping on features (except the graphic that is currently edited) on or off. snappingEnabled must be true for this option to have an effect.

The following properties can be added directly to layer configurations:

{
    "map": {
        "layers": [
            {
                "id": "mylayer",
                "type": "AGS_FEATURE",
                "url": ".../FeatureServer/0",
                "advancedEditing": {
                    "allowSnapping": true,
                    "allowEditing": true
                }
            }
        ]
    }
}
Property Type Description
allowSnapping Boolean If set to false, this layer is not used for snapping.
allowEditing Boolean If set to false, this layer is not provided for editing.

MergeViewModel

This component is the view model for the MergeWorkflowWidget. The following properties can be configured:

Property Type Description
attributeSkipList string[] A list of feature attribute names, that should not be displayed in the merge preview.

External API

The external API allows developers to start the editing and get the resulting feature after the edit is complete.

Usage

Add the Editing reference to your component.

{
    "name": "_editing",
    "providing": "advanced-editing.Editing"
}

Create a new feature

Create a new feature for a specified FeatureLayer. Pass the layer ID of the according layer.

this._editing.createFeature("areas").then(
    result => {
        // handle result
    },
    reason => {
        // error case
    }
);

Edit an existing feature

Edit an existing feature that belongs to a FeatureLayer. Pass the feature that must be an instance of esri/Graphic.

const featureLayer = this._mapWidgetModel.map.findLayerById("areas");
const queryParams = featureLayer.createQuery();
queryParams.where = "1=1";
featureLayer.queryFeatures(queryParams).then(results => {
    const feature = results.features[0];
    this._editing.editFeature(feature).then(
        result => {
            // handle result
        },
        reason => {
            // error case
        }
    );
});

Create a new geometry

Pass the geometry type to create a new esri/geometry/Geometry.

this._editing.createGeometry("polygon").then(
    result => {
        // handle result
    },
    reason => {
        // error case
    }
);

Edit an existing geometry

Pass an existing instance of esri/geometry/Geometry to allow the user to edit it.

const geometry = new Polygon({
    rings: [
        [
            [356517.0185643031, 5710524.887694486],
            [356537.11723534466, 5710522.300539059],
            [356541.35057714465, 5710473.352524496],
            [356477.78500000015, 5710478.9120000005],
            [356517.0185643031, 5710524.887694486]
        ]
    ],
    spatialReference: {wkid: 25832}
});
this._editing.editGeometry(geometry).then(
    result => {
        // handle result
    },
    reason => {
        // error case
    }
);

EditorInterceptor

To get direct access to the initialization properties of the Editor widget (for example to customize additional properties or watch for events), use this extension point. You can register multiple advanced-editing.EditorInterceptor instances.

class MyEditorInterceptor {
    intercept(editModel) {
        // Add your code
    }
}

In your manifest.json file, register the interceptor as advanced-editing.EditorInterceptor:

components: [
    {
        name: "MyEditorInterceptor",
        provides: "advanced-editing.EditorInterceptor"
    }
];