Offline data

Offline data

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 typeDownloaded 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 EditorVTPK + Item Resource Cache
    Offline-enabled vector tile serviceVTPK
    Offline-enabled map tile serviceTPK

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:

  1. Import data into ArcGIS or define a new dataset using data management tools.
  2. Create a new hosted feature layer item from the data.
  3. Go to the item page in ArcGIS.com or your ArcGIS Enterprise portal.
  4. In the Settings, scroll down to the Editing section.
  5. 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:

  1. Go to the item page of your hosted feature layer in ArcGIS.com or your ArcGIS Enterprise portal.
  2. In the Settings tab, scroll down to the Editing section.
  3. Click the Enable Sync (required for offline use and collaboration) and Enable editing check box, then Save.
  4. 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.

  • 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:

  1. 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:

    1. Set up your project using one of the ArcGIS Maps SDKs for Native Apps for your platform of choice within your preferred IDE.

    2. Define an area of interest from the feature layer you want to take offline.
    3. Create a GeodatabaseSyncTask referencing the hosted feature layer item.
    4. Get a set of default parameters to download the area of interest, and modify them to not download attachments.
    5. Create a GenerateGeodatabaseJob.
    6. Start the job and wait for it to complete, returning a ready to use Geodatabase that references the downloaded geodatabase file.
    7. Use this to access GeodatabaseFeatureTables. You can use a GeodatabaseFeatureTable to create an Feature Layer, which can be added to a map.
  2. 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 .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for SwiftArcGIS Maps SDK for KotlinArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)
    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
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    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.

ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for SwiftArcGIS Maps SDK for KotlinArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)
Expand
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
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.

ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for SwiftArcGIS Maps SDK for KotlinArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)
Expand
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
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.

ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for SwiftArcGIS Maps SDK for KotlinArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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 GeodatabaseFeatureTable object properties, such as Editable, CanAddFeature, EditableAttributeFields.

You can edit your offline data in the following ways:

Add a feature

  1. Create an in-memory Feature by calling CreateFeature() on a GeodatabaseFeatureTable.
  2. Optionally, modify the Feature's geometry and/or attributes.
  3. Add the Feature to the offline data by calling AddFeature() on the GeodatabaseFeatureTable.
ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for SwiftArcGIS Maps SDK for KotlinArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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

  1. Modify the geometry and/or attributes of the Feature.
  2. Pass the modified feature to UpdateFeature() on the feature's GeodatabaseFeatureTable.
ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for SwiftArcGIS Maps SDK for KotlinArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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

  1. Pass the Feature to DeleteFeature() on the feature's GeodatabaseFeatureTable.
ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for SwiftArcGIS Maps SDK for KotlinArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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

  1. Create a GeodatabaseSyncTask referencing the source feature service for the offline data.
  2. Use the GeodatabaseSyncTask to generate default SyncGeodatabaseParameters.
  3. Use the GeodatabaseSyncTask to create a GeodatabaseSyncJob.
  4. Start the job. If it completes without errors, the offline data and feature service will be in sync.
ArcGIS Maps SDK for .NETArcGIS Maps SDK for .NETArcGIS Maps SDK for SwiftArcGIS Maps SDK for KotlinArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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

Use Map Viewer and ArcGIS Online to create an offline-enabled web map.


Create an offline map area

Use ArcGIS Online or ArcGIS Enterprise to create an offline map area from an offline-enabled web map.


Create a mobile map package

Use ArcGIS Pro to create a mobile map package.


Workflows

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