Generate a local geodatabase from an online 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 click 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
- Create a
GeodatabaseSyncTask
with the URL of the feature service and load it. - Create
GenerateGeodatabaseReplicaParameters
specifying the extent and whether to include attachments. - Create a
GenerateGeodatabaseReplicaJob
withgeodatabaseSyncTask.GenerateGeodatabaseReplicaAsync(parameters, downloadPath)
. Start the job withjob.Start()
. - 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. - 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
<UserControl x:Class="ArcGISRuntime.WPF.Samples.GenerateGeodatabaseReplica.GenerateGeodatabaseReplica"
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" />
<Border Style="{StaticResource BorderStyle}">
<StackPanel>
<Button x:Name="MyGenerateButton"
Click="GenerateButton_Clicked"
Content="Generate Geodatabase"
IsEnabled="False" />
<ProgressBar x:Name="MyProgressBar"
MinHeight="10"
Visibility="Collapsed" />
</StackPanel>
</Border>
</Grid>
</UserControl>