Consider taking individual layers offline if you want to construct the map yourself and provide users with up-to-date information from ArcGIS Online or ArcGIS Enterprise. This topic describes how to take the following layers offline:
- Feature and annotation layers—Download a specific geographical area from a sync-enabled feature service into a mobile geodatabase. Edits can be synchronized with other users when connectivity is restored. This synchronization process allows the app to maintain an up-to-date view of the feature data.
- Tiled layers
You can export, download, and store these caches locally as packages and access them while your device is offline. You cannot edit this data, and if you require updates to the data, you must export and download them again.
Feature and annotation layers
You can take features (including annotation) offline, from a feature service, by downloading them to geodatabase feature tables within a mobile geodatabase. To do this, the feature service must be hosted on ArcGIS Enterprise 10.2.2 or later for features or from a service hosted in ArcGIS Online, provided that the feature service has been sync enabled (allow disconnected editing with synchronization).
Standard and feature-linked annotation can be taken offline from a feature service hosted on ArcGIS Enterprise 10.7.1 or later . Only feature-linked annotation can be edited. You can do this by editing the attributes and/or geographical position of any feature associated with feature-linked annotation. Edits will be applied to the annotation feature table and visible changes to the annotation will be reflected in the AGSMapView.
You can use an existing feature service or create features services for your own data. To enable sync for a feature service, do the following:
- ArcGIS Online—Edit the feature service item and check the Sync check box.
- ArcGIS Enterprise—See Prepare data for offline use in the ArcGIS Server documentation.
To create the mobile geodatabase, you must do the following:
- Generate geodatabase parameters and define the area of interest, the layers, any expression filters, and so on, if required.
- Create the geodatabase, populate it with all the relevant features, and download it to the user's device.
Generate geodatabase parameters
When you create a mobile geodatabase, you must provide a set of parameters, described below, to define exactly which data is downloaded.
- The geographical area of interest. You typically supply the area of interest as an extent (in other words, an envelope) but point, line, and polygon (including multipart) geometries are also supported. This allows you to create more detailed areas of interest. Regardless of the geometry, any features that intersect with the supplied area of interest are extracted.
- The spatial reference of the mobile geodatabase.
- Individual layers can be managed using the
- Determine which layers are included in the mobile geodatabase.
- Subset the features by providing an expression that filters features by attribute values, such as ZONE = 'COM'.
- The synchronization model controls how edits made to the mobile geodatabase are applied back to the feature service during synchronization. The model supported is defined by the data that was used to create the sync-enabled feature service. If the data is nonversioned, the synchronization model is per layer. This is the most flexible model, allowing you to synchronize on a layer-by-layer basis, based on the layers you specify. If the data is versioned, the synchronization model is per geodatabase. This synchronizes the entire geodatabase, including all layers and tables, at once.
- Specify whether to include feature attachments in the mobile geodatabase and whether they can be uploaded during synchronization.
- Identify whether tables related to the layer are also included in the geodatabase.
You can obtain a default set of parameters (AGSGenerateGeodatabaseParameters) using the defaultGenerateGeodatabaseParameters method on the AGSGeodatabaseSyncTask. If you provide the area of interest, the default parameters will be generated taking into account the capabilities supported by the ArcGIS feature service. You can update these default parameter values before creating the geodatabase.
Create the geodatabase
Obtain a job to generate and download the geodatabase by passing the AGSGenerateGeodatabaseParameters to the generateJob method on the AGSGeodatabaseSyncTask. Run the job to generate and download the geodatabase to the device.
Your geodatabase is now on the local machine or device.
If you generate the geodatabase using these methods, it will automatically register the geodatabase with its original service. This allows the data in the geodatabase to be synchronized with the original service. If you want to load this geodatabase onto a number of devices and allow those users to synchronize changes with the original service, you must register these individual geodatabases with the original service.
For details on synchronizing offline feature edits, see Sync offline edits.
Create layers from geodatabase feature tables
Now that you have a geodatabase on your local machine or device, you'll create the relevant layer from the geodatabase feature tables.
Geodatabases downloaded in this way can contain tables with one of two types of data: features and annotation (as of ArcGIS Runtime 100.6 and ArcGIS Enterprise 10.7.1).
- Get the geodatabase from the generate geodatabase job.
- Load the geodatabase.
- Create feature layers from the geodatabase feature tables.
- Create annotation layers from the geodatabase annotation tables.
Tiled layers typically provide geographical context to your maps as basemaps that display beneath your operational data. You can export and download tile caches directly to your device from any tiled data source that is export enabled. Esri provides a number of raster and vector basemaps for you to export and download:
- Download tiled data—Tiled ArcGIS map services, tiled ArcGIS image services, or tiled basemaps in ArcGIS Online
- Download vector tiled data—ArcGIS vector tile services or vector basemaps in ArcGIS Online
Download tiled data
You can take tiled data offline by exporting and downloading the tiled data as a tile package (.tpk) using the AGSExportTileCacheTask class. This task requires that the tiled map or image service support the creation of an offline tile cache; specifically, it must enable the exportTiles operation. This can be found at the bottom of the service's HTML page.
To create the tile cache, do the following:
- Generate the default export tile cache parameters and set any of the properties.
- Export and download the tile cache using the methods on the AGSExportTileCacheTask .
Generate default export tile cache parameters
Construct a default set of parameters ( AGS ExportTileCacheParameters) by passing an area of interest (polygon or envelope) along with the minimum and maximum scale thresholds to the exportTileCacheParameters method on the AGS ExportTileCacheTask.
This method will return a set of parameters for the area of interest and will calculate the levels of detail (LODs) required to support the minimum and maximum scale for the service's tiling scheme. You can adjust these LOD levels or remove some before you download the cache.
Export and download the tile cache
Obtain an export and download job by passing the AGSExportTileCacheParameters to the exportTileCacheJob method on the AGSExportTileCacheTask. Run the job to download the tile cache into a tile package that is placed in the download path on the device.
When creating an offline tile cache from a tiled service, consider the following:
- The export tiles operation used to generate tile caches is only available with services hosted on ArcGIS Server 10.2.1 or later.
- Estimation of tile cache size is not available on ArcGIS Online hosted tiled services.
- The time required to create a tile cache varies depending on the extent requested, the number of levels requested, the network connection speed, and so on. Use the estimateTileCacheSizeJobWithParameters method on the AGS ExportTileCacheTask class, which returns an AGS EstimateTileCacheSizeJob to get the approximate size of a tile cache for a specific set of parameters. Try generating a smaller tile cache to get an idea of how long caching will take when planning a large offline data capture event.
- There is a limit to the number of tiles you can generate in a single request. When generating a tile cache from an ArcGIS Online basemap, there is a limit of 100,000 tiles per request. Read more on this in the ArcGIS REST API documentation. Organizations that use their own ArcGIS Server to host an offline tile cache can configure the server's maxExportTilesCount via the administrator account to change the default limit of 100,000 tiles.
Download vector tiled data
You can take vector tiled data offline by exporting it from an ArcGIS vector tile service and downloading it as a vector tile package (.vtpk) using the AGS ExportVectorTilesTask class. The vector tile service used for this operation must support the creation of an offline vector tile cache; specifically, it must enable the exportTiles operation. Vector tiles contain vector representations of data that can be restyled for different purposes, such as day and night viewing. You can download default styling resources along with the vector tiles and custom style resources from ArcGIS Portal items that host vector tile layers.
You have a number of workflows available to you depending on whether your vector tiled data has custom style resources, whether you want to download many custom styles that you can apply to a number of tile caches, or whether you just want to obtain the default tile cache.
To create a vector tile package (.vtpk file) and vector tile style resources, do the following:
- Instantiate the export vector tiles task and check whether the vector tiles have custom style resources.
- Specify the export vector tile task parameters for a specific maximum scale and area of interest.
- Export the vector tiles. The vector tile package is populated with vector tiles and the default style resources from the ArcGIS vector tile service.
If your ArcGIS vector tile layer has custom style resources, export the vector tiles with custom style resources. If you only want to obtain the custom style resources, see export custom style resources.
Instantiate the export vector tiles task
Instantiate the AGS ExportVectorTilesTask using a URL to the portal item that represents an ArcGIS vector tiled layer. Load the task, and upon completion, check whether the vector tiles have custom style resources by checking the hasStyleResources Boolean value.
You can instantiate the AGS ExportVectorTilesTask with either of the following:
- A URL to the portal item that represents an ArcGIS vector tiled layer. This gives you the ability to enable with the layer's custom styles. (Recommended approach)
- A URL to the ArcGIS vector tile service itself. Use this option if you only want to display the service's default style.
Specify the export vector tiles task parameters
To obtain a default set of parameters, call the defaultExportVectorTilesParametersWithAreaOfInterest:maxScale:completion: method and provide an area of interest (polygon or envelope) and a maximum scale. When you provide the maximum scale, you must be aware that there won't be any tiles when the map is zoomed in beyond this scale. If you set the maximum scale to 0, the export will include all levels of detail in the service.
This method returns the set of default parameters, AGS ExportVectorTilesParameters, required to export the vector tiles to a vector tile package. The LODs have been calculated to support the maximum scale that you specified.
Export the vector tiles
Obtain a job to generate and download a vector tile package and its default style resources by passing the AGS ExportVectorTilesParameters to the exportVectorTilesJob method on the AGS ExportVectorTilesTask. You must also provide a download path to store the vector tile package and its default style resources.
Run the exportVectorTilesJob to export and download the vector tile package (.vtpk).
To obtain the vector tiles and the default style resources, you must instantiate the AGS ExportTileCacheTask with a URL to the ArcGIS vector tile service.
Export the vector tiles with custom style resources
Obtain a job to generate and download a vector tile package containing tiles and associated style resources by passing the AGS ExportVectorTilesParameters to the exportVectorTilesJob method on the AGS ExportVectorTilesTask. The portal item's associated style resources will be downloaded and saved separately. You must also provide a download path to store the vector tile package and a separate download path for the style resources.
Run the job to export and download the vector tile package (.vtpk) and the style resources to the device.
To obtain the vector tile package and its custom style resources, you must instantiate the AGS ExportVectorTilesTask with a portal item that represents an ArcGIS vector tiled layer.
Export custom style resources
Obtain a job to download any custom style resources associated with the tasks vector tiles by passing a download path to the exportStyleResourceCacheJob method on the AGS ExportVectorTilesTask.
Run the job to export the style resources. Obtain the AGS ItemResourceCache from the AGS ExportVectorTilesResult.
To obtain the custom style resources, you must instantiate the AGS ExportTileCacheTask with a portal item that represents an ArcGIS vector tiled layer.