Create an offline layer

To create an offline layer, you can use either the Services pattern, where you use ArcGIS Online or ArcGIS Enterprise to host a set of tile and feature services that are enabled for offline use, or you can use the Desktop pattern, where you author packages in ArcGIS Pro for sideloading onto your device, or you can create offline layers from local sources (such as mobile geodatabases, shapefiles, GeoPackages, and tile caches) and add them to your own offline map.

Instead of taking layers offline individually you can also take a whole map offline. For more details on how to take a map offline, see Create an offline map. The main advantage of working directly with layers instead a map is that you can control everything at a granular level. You can decide when and how individual offline layers are created, used and synchronized.

Services Pattern

The services pattern is best for supporting numerous users who share data. This pattern allows multiple offline users to edit the same data layer and synchronize edits later, when online.

For operational data, you can use a sync-enabled feature service from ArcGIS Online or ArcGIS Enterprise to create a mobile geodatabase for offline use. Through the synchronization process, you can control whether a user can upload their edits, download edits made by others, or both. This allows the app to maintain an up-to-date view of the data. When more than one user is editing the same feature and the edits conflict, the last edit synchronized to the service overrides those synchronized earlier. In a pre-planned workflow, you generate the geodatabase once and load it onto many of your users' devices, thus reducing the number of generate requests to the server. The pre-planned workflow requires you to register the geodatabase.

For basemap data, you can create raster tile caches on-demand from both ArcGIS tiled map services and ArcGIS Online basemaps. These caches can be stored locally and accessed whilst offline.

Operational data from a sync-enabled feature service

To continue viewing, interacting with and editing features you can take specific features and feature layers offline by storing them in geodatabase feature tables within a mobile geodatabase. The only limitations to this process are that the feature service must be from ArcGIS for Server 10.2.2 or later, or from a service hosted on ArcGIS Online, and the feature service must have sync enabled capabilities (allow disconnected editing with synchronization).

You can use a pre-existing feature service or create features services for your own data. To enable sync for a feature service:

  • In ArcGIS Online: you must edit the feature service item and check the Sync check box.
  • In ArcGIS Server: see Prepare data for offline use in the ArcGIS Server documentation.

To create a mobile geodatabase for offline use you need to:

  1. Specify the geodatabase parameters, such as the area of interest.
  2. Create the geodatabase using the methods on the GeodatabaseSyncTask. The geodatabase is populated with the relevant features (within the area of interest, for example) and downloaded to the device.
  3. Register the geodatabase if you are using a pre-planned workflow.

Specify the geodatabase parameters

When creating a mobile geodatabase, you can supply parameters to define:

  • Which layers to include in the mobile geodatabase.
  • The spatial reference of the mobile geodatabase.
  • The geographical area of interest. You typically supply the area of interest as an extent (envelope, in other words) 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.
  • A subset of features to copy to the geodatabase. You can provide an expression that filters features using attribute values, such as ZONE = 'COM'.
  • The synchronization model for the layers. 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 non-versioned, 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.
  • Whether to include feature attachments in the mobile geodatabase and whether they can be uploaded during synchronization.

You can construct a default set of these parameters (GenerateGeodatabaseParameters) using the createDefaultGenerateGeodatabaseParametersAsync method on the GeodatabaseSyncTask. The default values take into account the capabilities supported by the ArcGIS feature service and the data it contains. You can update these parameters before creating the geodatabase.

Create the geodatabase

Use the GeodatabaseSyncTask class to initiate a request for a geodatabase from a sync-enabled feature service for your area of interest. The method returns a GenerateGeodatabaseJob which once succeeded will provide access to the geodatabase.

Missing source code file

Register the geodatabase in a pre-planned workflow

If you want to generate the geodatabase once and load copies of it onto a number of devices then you must register the geodatabase copy on each device that uses one. This pre-planned workflow and has the following benefits:

  • Allows you to control which maps and data your users can access by pre-loading them onto your users' devices.
  • Allows you to schedule the geodatabase generation for off-peak hours.
  • Reduces load on the server. Multiple clients aren't generating a geodatabase for the same area because you've generated it for them.

For details and important tips on registering and unregistering geodatabases, see Register a geodatabase in a pre-planned workflow.

Basemap data from tiled map services

An offline copy of tiled map services (raster tiles) can be requested so that a basemap is available when the app is working in an offline environment. These copies can be downloaded in the form of a tile package (a .tpk file) using the ExportTileCacheTask class. The map service used for this operation must support the creation of an offline tile cache; specifically, it must support the exportTiles operation that appears at the bottom of the service's HTML page.

When requesting a tile cache, define the following properties:

  • The levels of detail (also known as LODs) to include in the tile cache
  • An area of interest (this can be a polygon geometry or an envelope)
  • A spatial reference for the tile cache (defined on the extent geometry of the cache)
  • The compression quality of the tile package (this affects its file size)

You can construct a default set of these parameters (ExportTileCacheParameters) by providing an area or interest and desired scale thresholds to the createDefaultExportTileCacheParameters method on the ExportTileCacheTask. This asynchronous method provides initialized parameters for exporting tiles. It will calculate the levels of detail (LODs) required based on the specified min and max scale and the tiling scheme of the service.

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 10.2.1 for Server 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 estimateTileCacheSize method on the ExportTileCacheTask class which returns an EstimateTileCacheTaskJob 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 admin account to change the default limit of 100,000 tiles.

Desktop Pattern

You can use ArcGIS Pro or ArcGIS Desktop to generate operational layers, basemaps, scene layers, locators and networks for use in ArcGIS Runtime. This workflow requires that you take this content, build your own maps and instantiate your own tasks to work with the locators and networks. If you'd like a ready-to-use and regularly updated locator (and network dataset) for your area of interest, you can license StreetMap Premium data (in MMPK format). For details, see Add StreetMap Premium data.

Create a mobile geodatabase for operational layers from ArcMap

To generate a geodatabase use the Share as > ArcGIS Runtime Content menu item as described in the ArcGIS help topic Creating ArcGIS Runtime content. This is available with ArcGIS 10.2.1 for Desktop or later.

Create a raster tile basemap

You can use ArcGIS Pro or ArcMap to create a raster tile basemap. For more details on how to set the format, tiling schemes, and levels of detail see:

After you sideload the tile package onto your device's file system, you can add it as a map's basemap.

Create a vector tile basemap

ArcGIS Pro allows you to author a map for vector tile creation and  create a vector tile package using a geoprocessing tool. You can add this local vector tile package (.vtpk) as a vector tiled layer (ArcGISVectorTiledLayer) to your ArcGIS Runtime app and create a basemap from it.