Editing means that you can add, update, and delete features. Updating features includes modifying feature attributes (changing the value of a feature's fields according to the type and range of values allowed); modifying feature geometry (such as moving a point feature or reshaping a polygon or polyline feature); and adding, updating, and deleting feature attachments. For example, if you are editing features representing wildlife sightings, the feature geometry can represent the sighting's location, the feature attributes can include the sighting's description and time, and you can add a photo of the sighted wildlife as an attachment to the feature.
Editing is supported in two workflows: online (connected) and offline (disconnected). Whether your app enables users to edit online, offline, or both, your workflow should include a feature service from ArcGIS for Server, ArcGIS Online, or Portal for ArcGIS. You can publish feature services using ArcGIS for Desktop, or create feature services hosted on ArcGIS Online using the ArcGIS for Developers website. For more information, see Prepare an editing environment. Ultimately, you will submit any edits made to features in your Runtime app to a feature service. In an online editing workflow, edits should be sent back to the associated service as soon as they are made. For an offline editing workflow, before going offline, create a geodatabase that contains the features you want to edit from a sync-enabled feature service. Edits made to those features while offline are stored in the geodatabase and can be synced with the originating feature service when back online.
With ArcGIS Runtime SDK , you can build an app that allows users to edit online, offline, or both. Two editing models are at your disposal, and the one you should choose depends on your requirements.
The two models are as follows:
- Feature table editing model—In this model, you create a feature table from a feature service or geodatabase, and then edit the features in this feature table using save and delete methods. A feature layer (AGSFeatureTableLayer class) displays your features on the map, but the editing operations are performed on the feature table (AGSGDBFeatureTable and AGSGDBFeatureServiceTable classes). This model supports both online and offline editing workflows.
- Feature layer editing model—In this model, a feature layer (AGSFeatureLayer class) displays your features on a map and also handles editing features. This model supports the online editing workflow only but provides additional capabilities not provided by the first model, as described below.
These two models are discussed below in the context of online and offline editing.
If you are building an app that always requires your users to have a network connection to view and edit features, you can choose between the two editing models described above. Using the feature table model, you can support online editing by creating an AGSGDBFeatureServiceTable from a feature service and displaying the features in a map using an AGSFeatureTableLayer. Using the feature layer model, you can support online editing by creating an AGSFeatureLayer from a feature service. The layer displays your features when added to a map, and edits are performed using API methods on the layer class. This AGSFeatureLayer model provides additional capabilities that are currently not supported by the AGSGDBFeatureServiceTable, including the ability to do the following:
- Query and edit layers created from nonspatial tables (as opposed to spatial layers) in a feature service.
- Query the related tables of a service layer.
- Edit the related tables of a service layer.
- View and work with time-aware layers and services.
If your app requires any of these capabilities, use the feature layer editing model. The editing methods are on the AGSFeatureLayer class. See Feature layer for more information.
If you are building an app to support both online and offline editing workflows, consider using the feature table editing model. This model brings together online and offline editing into a set of related classes, allowing you to reuse much of your code and greatly streamline writing editing components that work in both online and offline scenarios. For more information on editing feature tables online and offline, see Edit features. In contrast, the feature layer editing model does not support offline editing. Therefore, if you choose this model for your online editing, you must use the feature table editing model for the offline portion of your app. This will involve two separate code paths: one for editing online features in an AGSFeatureLayer, and one for editing offline features in an AGSGDBFeatureTable.
If you are building an app in which your users can edit features offline, use the feature table editing model, described in Edit features. Before going offline, create a geodatabase from a sync-enabled feature service using the API, as described in Create an offline map. Edit the features in the geodatabase on your local device when offline, and sync those edits back to the service when online again, as described in Sync offline edits.
Prepare an editing environment
Editing requires a feature service to provide the symbology, feature geometry, and set of attribute fields (schema) for your features. Feature services contain service layers (feature data) and tables (nonspatial, tabular data) that you edit via a feature table or feature layer in an online workflow, or use to prepare editable data for an offline workflow. For more information about feature services, see What is a feature service?
Before you build an app that performs editing, you need a feature service that exposes the layers you want to edit. There are various ways to publish a feature service.
- You can login to your organization's portal and publish features from a variety of data sources such as CSV files, GeoJSON, shapefiles, feature collections, or file geodatabases. All of these options and their steps are outlined in the publish hosted feature services topic.
- You can publish feature services using ArcGIS for Desktop. This involves setting up a map document, and defining a feature class schema or importing an existing feature class. Optionally, you can define feature templates to make it easy for the app's end user to create common features. You can then publish the map as a service to an ArcGIS for Server or as a hosted service in ArcGIS Online or Portal for ArcGIS. You must enable Feature Access capability and ensure that the service is sync-enabled. This generates a URL through which you can access the feature service.
- You can create a feature layer using the ArcGIS for Developers site. Log in to the site using your organization account or your free developers subscription. Access the Layers tab and click the Create New Layer button. Follow the instructions to create the new feature layer ensuring that you have checked the box to enable the layer to be taken offline to allow it to be viewed, edited, and synchronized. After creating a layer you can add data to it in the ArcGIS Online Map Viewer.
For an offline editing workflow, create a sync-enabled feature service. A sync-enabled feature service allows you to generate a geodatabase for offline use, and gives you the ability to sync your local edits back to the service.
ArcGIS 10.2.2 for Server or later is required to publish sync-enabled feature services.
Edits made to features in your Runtime application need to be committed back to the feature service. In an online editing workflow, edits should be sent back to the service as soon as they are made. For an offline editing workflow, sync edits made while offline back to the service, as described in Sync offline edits.
You can program editing capabilities into your applications in two ways: using the API directly or using the editing toolkit components. For more fine-grained control of the editing experience, developers can perform edits by using methods directly on the feature layers in the map. For easier and more rapid development, developers can edit using the AGSPopupsContainerViewController, taking advantage of the AGSPopupInfo that abstracts away the fine-grained editing methods.
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.
The editing framework supports the tracking of specific edits to features. This happens by tracking the following feature properties:
- Which user created the feature
- Date and time the feature was created
- Which user last edited the feature
- Date and time the feature was last edited