What is offline data?
Offline data is data that is generated and downloaded from an offline-enabled data service, such as the basemap styles service (including default basemap styles and custom basemap styles created using the Vector Tile Style Editor), feature services, vector tile services, and map tile services.
You use offline data to create offline apps that:
- Support disaster recovery operations when infrastructure has been damaged.
- Enable mobile workers to collect and edit data.
- Provide current, detailed maps to large workforces.
- Display offline vector tile or map tile basemap layers.
Types of offline data
There are two types of offline data:
-
Feature data is data created from a feature service. The offline data is downloaded as a geodatabase file that can contain data for feature layers, non-spatial tables, and attachments. This data can be created, updated, or deleted according to the capabilities of the source feature service. Offline data edits can be synchronized with the source feature service whenever a network connection is available. To support offline data, the feature service must be sync-enabled. Later, when the offline data is no longer needed, you should unregister geodatabase to clean up the tracking metadata stored on the feature service.
-
Tile data is data created from one of the following service types and downloaded as a read-only package of static tiles. Depending on the type of service, tiles will be downloaded as vector tiles or map tiles:
Source tile service type Downloaded files Basemap styles service (vector basemap layer) VTPK + Item Resource Cache Basemap styles service (image basemap layer) TPK Custom basemap style created with the Vector Tile Style Editor VTPK + Item Resource Cache Offline-enabled vector tile service VTPK Offline-enabled map tile service TPK
How to work with offline data
The general workflow to work with offline data in an offline application is:
1. Create
To begin working with offline data, you need to create a data service. To create a data service, you use a data management tool to publish a new service. The most common workflow is to import data from external data sources to create new feature layers in a feature service. Once a feature layer (and feature service) is created, you can publish additional types of services such as vector tile services and map tile services. For each service published, a hosted layer (item) is also created so you can access and manage the service and the layers within it.
The typical steps to create a feature service, vector tile service, or map tile service are:
- Import data into ArcGIS or define a new dataset using data management tools.
- Create a new hosted feature layer item from the data.
- Go to the item page in ArcGIS.com or your ArcGIS Enterprise portal.
- In the Settings, scroll down to the Editing section.
- Click the Enable Sync (required for offline use and collaboration) and Enable editing check box, then Save.
2. Manage
Once your service is published, you need to enable it for offline use. Go to the Settings tab in the item page of the service to enable it for offline use. You also need to set a proper sharing level for your service in order for it to be discoverable.
The typical steps to manage a feature service, vector tile service , or map tile service are:
- Go to the item page of your hosted feature layer in ArcGIS.com or your ArcGIS Enterprise portal.
- In the Settings tab, scroll down to the Editing section.
- Click the Enable Sync (required for offline use and collaboration) and Enable editing check box, then Save.
- Optionally, configure the item and service properties, editing and synchronization, and sharing and security settings for your feature service.
3. Access
After publishing a data service and enabling it for offline use, you can request a geographic area covered within that service to be taken offline. The service will generate offline data which you can then download to your device. You will also specify where to store the downloaded data on your local device.
After you download offline data, you can apply it to your map. The capabilities you can do with your offline data depend on the source service:
-
If your source service is a feature service, you can query, edit features, and use feature layer in your map. You can also synchronize your offline edits with the source feature service, or unregister geodatabase when you no longer need the offline data.
Geodatabase unregistration
When you download offline data from a feature service, the offline data is downloaded as a geodatabase file and registered with the feature service. This allows the feature service to track edits and compare its state with the offline data, and enables synchronizing the offline data with the feature service. When the offline data is no longer needed, it is best practice to unregister it to clean up the tracking metadata stored on the feature service.
Geodatabase unregistration is the process of removing the association between a local geodatabase containing offline data and the corresponding feature service on the server. Once unregistered, changes made to the local geodatabase will not synchronize back to the server. To unregister, a network connection is required.
-
If your source service is a vector tile service, you can add the vector tile package (VTPK) and optional item resource cache as a basemap to your map.
-
If your source service is a map tile service, you can add the tile package (TPK) as a basemap to your map.
There are two steps to access offline data:
-
When you download offline data and apply it on your map for the first time. This requires a network connection. The typical steps to access a feature service, vector tile service , or map tile service in your offline app are:
-
Set up your project using one of the ArcGIS Maps SDKs for Native Apps for your platform of choice within your preferred IDE.
- Define an area of interest from the feature layer you want to take offline.
- Create a
Geodatabase
referencing the hosted feature layer item.Sync Task - Get a set of default parameters to download the area of interest, and modify them to not download attachments.
- Create a
Generate
.Geodatabase Job - Start the job and wait for it to complete, returning a ready to use
Geodatabase
that references the downloaded geodatabase file. - Use this to access
Geodatabase
. You can use aFeature Tables Geodatabase
to create anFeature Table Feature Layer
, which can be added to a map.
-
-
When you access previously downloaded offline data from your local storage. This does not require a network connection.
If your source service is a feature service, you start by creating a
Geodatabase
from the downloaded geodatabase file:ArcGIS Maps SDK for .NET ArcGIS Maps SDK for .NET ArcGIS Maps SDK for Swift ArcGIS Maps SDK for Kotlin ArcGIS Maps SDK for Java ArcGIS Maps SDK for Qt Use dark colors for code blocks Copy Geodatabase offlineGeodatabase = await Geodatabase.OpenAsync("path\\to\\file.geodatabase");
Code examples
Display offline data from a feature service
After you create and manage your feature service, you can access offline data from your feature service in your offline app.
var featureServiceUri = new Uri("https://services2.arcgis.com/ZQgQTuoyBrtmoGdP/arcgis/rest/services/WaterDistributionNetwork/FeatureServer");
GeodatabaseSyncTask geodatabaseSyncTask = await GeodatabaseSyncTask.CreateAsync(featureServiceUri);
GenerateGeodatabaseParameters gdbGenerateParameters
= await geodatabaseSyncTask.CreateDefaultGenerateGeodatabaseParametersAsync(areaOfInterest.Extent);
gdbGenerateParameters.ReturnAttachments = false;
GenerateGeodatabaseJob job = geodatabaseSyncTask.GenerateGeodatabase(gdbGenerateParameters, "path\\to\\file.geodatabase");
// Optionally listen for progress changes
job.ProgressChanged += (o,e) => { };
Geodatabase generateResult = await job.GetResultAsync();
MainMapView.Map.OperationalLayers.AddRange(
generateResult.GeodatabaseFeatureTables.Select(table => new FeatureLayer(table))
);
Display offline data from a vector tile service
After you create and manage your vector tile service, you can access offline data from your vector tile service in your offline app.
ExportVectorTilesTask exportVectorTileCacheTask = await ExportVectorTilesTask.CreateAsync(hostedItem);
ExportVectorTilesParameters exportVectorTilesParams = await exportVectorTileCacheTask.CreateDefaultExportVectorTilesParametersAsync(
areaOfInterest: areaOfInterest,
maxScale: 100);
ExportVectorTilesJob exportJob = exportVectorTileCacheTask.ExportVectorTiles(
parameters: exportVectorTilesParams,
vectorTileCachePath: "path\\to\\something.vtpk",
itemResourceCachePath: "path\\to\\cache\\dir");
ExportVectorTilesResult exportResult = await exportJob.GetResultAsync();
var offlineVectorTileLayer = new ArcGISVectorTiledLayer(
vectorTileCache: exportResult.VectorTileCache,
itemResourceCache: exportResult.ItemResourceCache
);
MainMapView.Map.Basemap = new Basemap(offlineVectorTileLayer);
Display offline data from a map tile service
After you create and manage your map tile service, you can access offline data from your map tile service in your offline app.
ExportTileCacheTask exportImageTilesTask = await ExportTileCacheTask.CreateAsync(imageTileUrl);
ExportTileCacheParameters exportImageTileParams = await exportImageTilesTask.CreateDefaultExportTileCacheParametersAsync(
areaOfInterest: areaOfInterest,
minScale: 500_000_000,
maxScale: 10_000_000);
ExportTileCacheJob exportImageTilesJob = exportImageTilesTask.ExportTileCache(exportImageTileParams, "\\path\\to\\file.tpk");
TileCache exportImageTileCacheResult = await exportImageTilesJob.GetResultAsync();
ArcGISTiledLayer imageTiledLayer = new ArcGISTiledLayer(exportImageTileCacheResult);
Edit offline data from a feature service
After you create, manage, and access your feature service, you can perform edits on the data from the feature service while disconnected. Edits are stored on device storage and you must synchronize the edits with the feature service when you go back online. The owner of a feature service can configure how data can be edited. In your offline application, you can read the configuration settings from the Geodatabase
object properties, such as Editable
, Can
, Editable
.
You can edit your offline data in the following ways:
Add a feature
- Create an in-memory
Feature
by callingCreate
on aFeature() Geodatabase
.Feature Table - Optionally, modify the
Feature
's geometry and/or attributes. - Add the
Feature
to the offline data by callingAdd
on theFeature() Geodatabase
.Feature Table
var newFeature = geodatabaseFeatureTable.CreateFeature();
newFeature.Geometry = new MapPoint(x: -117.157, y: 32.707, spatialReference: SpatialReferences.Wgs84);
newFeature.SetAttributeValue("Name", "Friar's house");
try
{
await geodatabaseFeatureTable.AddFeatureAsync(newFeature);
}
catch(Exception ex)
{
// Report the error
}
Update a feature
- Modify the
geometry
and/orattributes
of theFeature
. - Pass the modified feature to
Update
on the feature'sFeature() Geodatabase
.Feature Table
existingFeature.Geometry = new MapPoint(x: -1.9025, y: 52.4559, spatialReference: SpatialReferences.Wgs84);
existingFeature.SetAttributeValue("Name", "Edgbaston");
if (existingFeature.FeatureTable is FeatureTable featureTable)
{
try
{
await featureTable.UpdateFeatureAsync(existingFeature);
}
catch (Exception ex)
{
// Report the error
}
}
Delete a feature
- Pass the
Feature
toDelete
on the feature'sFeature() Geodatabase
.Feature Table
if (existingFeature.FeatureTable is FeatureTable featureTable)
{
try
{
await featureTable.DeleteFeatureAsync(existingFeature);
}
catch (Exception ex)
{
// Report the error
}
}
Synchronize offline data with source feature service
After you create, manage, access, and make offline edits to offline data from a feature service, you can synchronize the edits with its source feature service. This operation requires a network connection.
You can choose whether to upload edits from offline data to the source feature service, download edits from the source feature service to the offline data, or both (default configuration).
Steps
- Create a
Geodatabase
referencing the source feature service for the offline data.Sync Task - Use the
Geodatabase
to generate defaultSync Task Sync
.Geodatabase Parameters - Use the
Geodatabase
to create aSync Task Geodatabase
.Sync Job - Start the job. If it completes without errors, the offline data and feature service will be in sync.
Uri serviceUrl = offlineGeodatabase.Source;
GeodatabaseSyncTask gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(serviceUrl);
SyncGeodatabaseParameters offlineSyncParams = await gdbSyncTask.CreateDefaultSyncGeodatabaseParametersAsync(offlineGeodatabase);
SyncGeodatabaseJob syncJob = gdbSyncTask.SyncGeodatabase(offlineSyncParams, offlineGeodatabase);
IReadOnlyList<SyncLayerResult> syncResult = await syncJob.GetResultAsync();
if (syncJob.Status != Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded)
{
// Handle errors
}
Tutorials
Create an offline-enabled web map
Create an offline map area
Use your portal to create an offline map area from an offline-enabled web map.
Create a mobile map package
Workflows
Create an app using a web map (ahead of time)
Learn how to build an offline app using an offline-enabled web map using the ahead-of-time method.
Create an app using a web map (on-demand)
Learn how to build an offline app using an offline-enabled web map using the on-demand method.
Create an app using a web map with layers (ahead of time)
Learn how to build an offline app using an offline-enabled web map and feature layer using the ahead-of-time method.
Create an app using a web map with layers (on-demand)
Learn how to build an offline app using an offline-enabled web map and feature layer using the on-demand method.