Edit and sync features

View inAndroidFormsUWPWPFWinUIiOSView on GitHubSample viewer app

Synchronize offline edits with a feature service.

Image of edit and sync features

Use case

A survey worker who works in an area without an internet connection could take a geodatabase of survey features offline at their office, make edits and add new features to the offline geodatabase in the field, and sync the updates with the online feature service after returning to the office.

How to use the sample

Pan and zoom to position the red rectangle around the area you want to take offline. Click "Generate geodatabase" to take the area offline. When complete, the map will update to only show the offline area. To edit features, click to select a feature, and click again anywhere else on the map to move the selected feature to the clicked location. To sync the edits with the feature service, click the "Sync geodatabase" button.

How it works

  1. Create a GeodatabaseSyncTask from a URL to a feature service.
  2. Use createDefaultGenerateGeodatabaseParametersAsync() on the geodatabase sync task to create GenerateGeodatabaseParameters, passing in an Envelope extent as the parameter.
  3. Create a GenerateGeodatabaseJob from the GeodatabaseSyncTask using generateGeodatabaseAsync(...), passing in the parameters and a path to where the geodatabase should be downloaded locally.
  4. Start the job and get the result Geodatabase.
  5. Load the geodatabase and get its feature tables. Create feature layers from the feature tables and add them to the map's operational layers collection.
  6. Create SyncGeodatabaseParameters and set the sync direction.
  7. Create a SyncGeodatabaseJob from GeodatabaseSyncTask using .syncGeodatabaseAsync(...) passing in the parameters and geodatabase as arguments.
  8. Start the sync job to synchronize the edits.

Relevant API

  • FeatureLayer
  • FeatureTable
  • GenerateGeodatabaseJob
  • GenerateGeodatabaseParameters
  • GeodatabaseSyncTask
  • SyncGeodatabaseJob
  • SyncGeodatabaseParameters
  • SyncLayerOption

Offline data

This sample uses a San Francisco offline basemap tile package.

About the data

The basemap uses an offline tile package of San Francisco. The online feature service has features with wildfire information.

Tags

feature service, geodatabase, offline, synchronize

Sample Code

EditAndSyncFeatures.xamlEditAndSyncFeatures.xamlEditAndSyncFeatures.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<UserControl x:Class="ArcGISRuntime.WPF.Samples.EditAndSyncFeatures.EditAndSyncFeatures"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView" GeoViewTapped="GeoViewTapped" />
        <Border Style="{StaticResource BorderStyle}">
            <StackPanel>
                <TextBlock x:Name="MyHelpLabel"
                           FontWeight="SemiBold"
                           Text="1. Click 'Generate geodatabase'"
                           TextAlignment="Center" />
                <Button x:Name="MyGenerateButton"
                        Margin="0,5,0,5"
                        Click="GenerateButton_Clicked"
                        Content="Generate geodatabase"
                        IsEnabled="False" />
                <Button x:Name="MySyncButton"
                        Click="SyncButton_Click"
                        Content="Sync geodatabase"
                        IsEnabled="False" />
                <ProgressBar x:Name="MyProgressBar"
                             MinHeight="15"
                             Margin="0,5,0,0"
                             Visibility="Collapsed" />
            </StackPanel>
        </Border>
    </Grid>
</UserControl>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.