Generate geodatabase replica from feature service

View inFormsWPFWinUIView on GitHub

Generate a local geodatabase from an online feature service.

Image of generate geodatabase replica from feature service

Use case

Generating geodatabases is the first step toward taking a feature service offline. It allows you to save features locally for offline display.

How to use the sample

Zoom to any extent. Then tap the generate button to generate a geodatabase of features from a feature service filtered to the current extent. A red outline will show the extent used. The job's progress is shown while the geodatabase is generated.

How it works

  1. Create a GeodatabaseSyncTask with the URL of the feature service and load it.
  2. Create GenerateGeodatabaseReplicaParameters specifying the extent and whether to include attachments.
  3. Create a GenerateGeodatabaseReplicaJob with geodatabaseSyncTask.GenerateGeodatabaseReplicaAsync(parameters, downloadPath). Start the job with job.Start().
  4. When the job is done, job.GetResultAsync() will return the geodatabase. Inside the geodatabase are feature tables which can be used to add feature layers to the map.
  5. Call syncTask.UnregisterGeodatabaseAsync(geodatabase) after generation when you're not planning on syncing changes to the service.

Relevant API

  • GenerateGeodatabaseReplicaJob
  • GenerateGeodatabaseReplicaParameters
  • Geodatabase
  • GeodatabaseSyncTask

Tags

disconnected, local geodatabase, offline, replica, sync

Sample Code

GenerateGeodatabaseReplica.xamlGenerateGeodatabaseReplica.xamlGenerateGeodatabaseReplica.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
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGISRuntime.Samples.GenerateGeodatabaseReplica.GenerateGeodatabaseReplica"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Button x:Name="myGenerateButton"
                Grid.Row="0"
                Clicked="GenerateButton_Clicked"
                IsEnabled="False"
                Text="Generate" />
        <ProgressBar x:Name="myProgressBar"
                     Grid.Row="1"
                     IsVisible="False"
                     MinimumHeightRequest="10" />
        <esriUI:MapView x:Name="myMapView" Grid.Row="2" />
    </Grid>
</ContentPage>

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