Editing features on the map
What can I do with editing?
The ArcGIS Runtime SDK for WPF provides simple feature editing. When editing data you can add, move, delete, cut, union, and reshape features. You can also edit feature attributes. If you attempt to modify the same feature at the same time as someone else, the last edits submitted are the ones committed to the database.
For some editing workflows, it's a good idea to have an analyst using ArcGIS for Desktop periodically review the edits to verify data integrity. Although components in the API can perform some data validation, other tasks such as validating topologies cannot be performed.
How do I add editing functionality to my application?
Once you've added an editable feature layer to your application, you can start using edit components in the API. The easiest way to get started is to use the out-of-the-box controls included with the ArcGIS Toolkit (ESRI.ArcGIS.Client.Toolkit.dll) library. The following widgets are available:
Editor Widget
The Editor Widget is the default editing interface included with the API. It is a templateable control that includes a toolbar and a template picker to select the type of feature to add. Feature service capabilities and property settings on the control dictate which tools are displayed and how they function.
If you do not use the Editor Widget, you need to code your own editing experience. However, you can still take advantage of other edit controls in the ArcGIS Toolkit, such as the Template Picker, Feature Data Form and Feature Data Grid.
Template Picker
The Template Picker displays a set of preconfigured feature choices that the user can create. The symbols visible in the Template Picker can come from either the editing templates defined in the feature service's source map, or they can be a set of symbols that are defined in the application. The Template Picker is a great way to expose preconfigured feature types for easy editing and quality control.
A Template Picker is included in the Editor Widget. The Template Picker can optionally be used on its own as a simple legend for your map.
Feature Data Form and Feature Data Grid
When you make attributes available for editing, you need to provide an interface for users to edit the attributes, and you must ensure that the data they enter is valid. The Feature Data Form and Feature Data Grid are controls that can help you with both these tasks.
The Feature Data Form reads the attribute fields available through your feature layer and generates a user interface for easily updating those fields. The Feature Data Grid presents attribute fields and values of a graphic layer in a data grid. If the Feature Data Grid contains attributes for an editable feature layer, attribute values can be edited directly within the control. Commit the edits by either navigating away from the edited cell or explicitly saving the edits, depending on feature layer settings.
Both controls validate data entered in the fields, ensuring that the input matches the expected data type. For example, if a coded value domain is applied to a field, the permitted values appear in a drop down list, restricting the possibility of other values being entered. If a field requires a date value, a calendar appears, helping the user to supply a valid date. All available fields in the layer are included for editing. If you want to restrict the available attributes, you must code your own interface for entering and validating values.
How does the editing work?
Editing with the ArcGIS Runtime SDK for WPF requires a feature service. Editing workflows can also take advantage of the ArcGIS for Server geometry service.
The role of the feature service
Editing requires a feature service to provide the symbology and feature geometry for editable data. The feature service is just a map service with the Feature Access capability enabled. This capability allows the map service to expose feature geometries and their symbols in a way that is easy for applications to use and update.
Before you build an editing application, you need to do some work to create a feature service exposing the layers that you want to be edited. This involves setting up a map document and, optionally, defining some templates for editing. Templates allow you to pre-configure the symbology and attributes for some commonly-used feature types. For example, to prepare for editing roads, you may configure templates for "Controlled Access Freeway", "Other Divided Highway", "State Highway", and "Local Road". Templates are optional, but they make it easy for the end user of the application to create common features.
Once your map is finished, you need to publish it to ArcGIS for Server with the Feature Access capability enabled. This creates REST URLs, or endpoints, to both a map service and a feature service. You will use these URLs to reference the services in your application.
Feature services are easily accessible in the ArcGIS Runtime SDK for WPF using a feature layer. Feature layers do a variety of things and can reference either feature layers in a map service or feature services; however, when you use a feature layer for editing purposes you need to reference a feature service.
While editing, your application tells the feature layer which attributes have changed and, if applicable, how the geometry has changed. The feature layer also displays the updated features after editing. Edits can be applied immediately or you can explicitly commit edits at your discretion.
The role of the geometry service
The ArcGIS for Server geometry service helps perform common editing operations such as creating, cutting, and reshaping geographic features. Before you use the Editor Widget, you need to create a geometry service on your ArcGIS for Server or use a public ArcGIS for Server geometry service. When you create the Editor Widget, you must provide the URL to the geometry service. The control uses the service behind the scenes. If features are autoselected, geometry operations can be used on editable feature layers. Otherwise, features must be explicitly selected before geometry operations are enabled in the control.
Custom editing solutions
If you decide not to use the Editor Widget, you can still use the Editor component and a set of edit commands to add, edit, and select features or methods and classes related to the feature layer. While an "edit toolbar" is not provided out of the box, you can use a set of commands within the context of a toolbar. Commanding controls, such as ButtonBase and Hyperlink, in the WPF platform, define their Command and CommandParameter properties using a set of Editor commands. The Editor maintains the following set of commands (implement ICommand):
- Add-draw and add new graphics.
- CancelActive-cancel the active command on the map.
- ClearSelection-unselect all graphics.
- Cut-uses a geometry service to cut graphics along a user-defined line.
- DeleteSelected-deletes selected graphics. If graphics are associated with an editable feature layer, features are deleted from the database.
- EditVertices-edits the vertices of any graphic clicked by the user.
- Move-click and drag a graphic to a new location.
- Reshape-uses a geometry service to reshape graphics with a user-defined line.
- Save-commits unsaved edits in all feature layers.
- Union-uses a geometry service to union graphics selected by the user.
See the Editor class in ESRI.ArcGIS.Client assembly/namespace in the library reference for additional information and use of the Editor.
Designing your editing experience
When you build an editing application, it's important to think about who will use the application and what they will need to do. You should provide your users with no more or no less than the tools they need. In most situations you can design an appropriate editing experience for your users through a combination of editing controls and tools included with this API. Keep in mind that although the API includes a comprehensive Editor Widget to help you get started, this particular widget may not be the best fit for your scenario.
Consider the following approaches for designing an editing application. Each approach has its own merits and types applications for which it is most appropriate.
Feature sketching
In this type of application, field analysts need to sketch simple events on the map, for example, bird sightings. The geographic precision of the edits is not as important as the event's attributes and the fact that the event happened. In this type of an application, you can use a Template Picker to limit the types of items users can sketch. The Feature Data Form is also useful, either in a side panel or in an info window that appears when the feature is clicked. Options for splitting and merging features, adding a point at an X/Y location, snapping, or uploading feature attachments may clutter the application and should be avoided unless absolutely needed.
Attribute-only editing
Some editing applications include a mapping component, but do not require changing feature geometry. For example, you may want to create an application allowing any office employee to edit the attributes of a parcel feature in your database. You want to prevent them from editing the geometry, leaving that task to your GIS analysts. In this scenario, you can include a map in your application, but expose editing only through the Feature Data Form or Feature Data Grid. A simple map click on a parcel displays the attributes to be edited. You do not need to include any buttons or controls for creating, deleting, or reshaping features.
Editing adjacent polygons
In some situations, you want users to be able to reshape existing polygons or edit their attributes without causing any gaps or overlaps between features. The features may represent sales districts within a region, or voter precincts within a county. Your editors may not be GIS professionals who understand concepts such as topological relationships, vertices, or snapping. You need to provide them with a subset of tools such as Union, Cut, and Reshape that modify features while preserving topological integrity. Tools for adding or deleting features and editing attributes is optional in this type of application.
Citizen participation, or geo-wiki
In this type of application, citizens can be the editors and report problems to a government organization by placing points on the map and including ancillary information such as photographs or a brief description. Users of this type of application are usually unaware that they are editing GIS data. They are only allowed to add point features to the database, using a carefully selected set of incident types predefined in a Template Picker. Attribute editing may be allowed to a very limited degree so that citizens can describe the incidents.
In this type of application, you may have to code some security checks to ensure that users can only edit or delete their own incidents. You may also include logic to periodically clean out the database, or allow a subset of authenticated users to close or delete incidents.
Specialized field work
Some applications are designed for specific types of field work and a refined audience. Suppose you have many field analysts in charge of updating a streets database. When building them an application for field work, you can choose to allow creation and deletion of line features only. Snapping is enabled, but only on the street network layer. The Template Picker makes it easy to denote which type of street is being created (unpaved road, paved minor road, arterial, and so on). Attribute editing is optional and can help analysts set other selected properties. However, you may choose to limit the attributes available for editing to keep the application usable and preserve screen real estate.