You can provide offline maps to users so they can be productive when their network connectivity is poor or nonexistent. To create offline maps, you create geodatabases and tile caches and then build layers from those, as described in this topic.
You can add capabilities for the following:
- Viewing basemaps (also known as tiled layers, created from tile caches).
- Editing operational data (also known as feature data and vector data). This includes querying and editing the location, shape, attributes, related tables, and attachments of features.
- Syncing edits when online again (upload their edits and/or pull down only the updated features that others have edited), if your data is service based.
- Performing blazing fast searches for locations (geocode and reverse geocode) and routes. For details, see Search for coordinates and Find a route.
An app licensed at the Basic level can include viewing offline basemaps and viewing offline feature data contained in a geodatabase. You must license your app at the Standard level if it includes any of the following functionality: offline editing, syncing offline edits with an upload, offline routing, offline geocoding, and any use of the Local Server. See License your app for more information on license levels.
Two main patterns are available for ArcGIS Runtime offline:
- Services pattern—Best for supporting a large number of users, this pattern allows multiple offline users to edit the same data layers and sync edits later, when online.
- Desktop pattern—Best for supporting applications with read-only data that requires periodic updates.
ArcGIS Runtime SDKs for Java, Qt, .NET (Desktop), and WPF offer a third pattern to use offline maps: the local server pattern. It's recommended that you use the services or desktop pattern instead; however, be aware that these patterns do not contain some capabilities that the local server pattern does, such as offline geoprocessing.
The services pattern is best for supporting a large number of users. This pattern allows multiple offline users to edit the same data layers and sync edits later, when online.
For operational data, you can use a sync-enabled feature service from ArcGIS for Server, ArcGIS Online, or Portal for ArcGIS to generate the geodatabase for offline use. Through the synchronization process, you can control whether a user can upload their changes, download others' changes, or both. This allows the application to have 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 the others.
In one workflow, sometimes referred to as a pre-planned workflow, you generate the geodatabase once and load it onto your users' devices. This workflow requires you to register a geodatabase.
For basemap data, ArcGIS tiled map services and ArcGIS Online basemaps allow for the on-demand creation of tile caches, letting you take your basemaps offline.
The desktop pattern, which allows a user to consume ArcGIS Runtime content created in ArcGIS for Desktop, is best for supporting apps with read-only data requiring periodic updates. This content can include features, tabular data, tile caches, network datasets for directions, and locators. For more information on creating ArcGIS Runtime content using ArcGIS for Desktop, see Creating ArcGIS Runtime content.
Include operational data
You can prepare operational data for offline use in one of two ways:
- Generate a geodatabase from a sync-enabled feature service using the API (services pattern).
- Generate a geodatabase using ArcGIS for Desktop (desktop pattern).
This section describes preparing operational data and adding it to your app.
Generate a geodatabase from a sync-enabled feature service
To generate a geodatabase for offline use, you need a feature service from ArcGIS 10.2.2 for Server or later or a service from ArcGIS Online. The feature service must be enabled for sync. You can publish feature services using ArcGIS for Desktop or create feature services hosted on ArcGIS Online using the ArcGIS for Developers website. To enable sync for a feature service in ArcGIS Online, edit the feature service item in ArcGIS Online, and check the Sync check box. Once you have a sync-enabled feature service, you can generate a geodatabase for your area of interest; this creates a copy of your features that you can work with offline.
To generate a geodatabase for offline use:
- Specify parameters—Before generating a geodatabase, specify parameters for its creation, such as the area of interest.
- Generate a geodatabase—Request and download copies using the methods on the GeodatabaseSyncTaskclass.
- Register a geodatabase—After generating the geodatabase you may need to register it.
When generating a geodatabase for offline use, you supply parameters allowing you to control the following:
- The layers to include in the generated geodatabase
- The extent of the generated geodatabase (and the spatial reference of this extent)—The extent of the geodatabase requested from the ArcGIS feature service is typically an envelope. However, point, line, and polygon (including multipart) geometries are supported, allowing for more complex data extractions to be defined. Regardless of the geometry type, features that intersect with the supplied geometry are extracted.
- The spatial reference of the generated geodatabase
- Whether or not to include feature attachments in the generated geodatabase
- The synchronization model for the geodatabase—The synchronization model controls how edits made to the geodatabase in the field 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 only include a subset of the features in the specified extent, by specifying layer queries to filter features by attribute values
Generate a geodatabase
To request a geodatabase from a sync-enabled feature service for your area of interest, use the GeodatabaseSyncTaskclass for this, after setting up your GenerateGeodatabaseParameters for the task.
Your geodatabase should now be on your local machine or device.
Register a geodatabase in a pre-planned workflow
In a services pattern workflow known as a pre-planned workflow, you generate the geodatabase once and load copies of it onto each user's device.
This workflow has the following benefits:
- Allows you to control which maps/geodatabase your users can select from. You can pre-load your maps/geodatabase onto your users' devices.
- Allows you to schedule the geodatabase generation for off-peak hours.
- Reduces the load on the server. Multiple clients aren't generating a geodatabase for the same area because you've generated it for them.
If you use this workflow, you must register the geodatabase (copy) on each device that uses it. For details and important tips on registering and unregistering geodatabases, see Register a geodatabase in a pre-planned workflow in "Sync offline edits."
Generate a geodatabase from ArcGIS for Desktop
Use ArcGIS 10.2.1 for Desktop or later to generate a geodatabase using the Share as > ArcGIS Runtime Content menu item as described in the ArcGIS help topic Creating ArcGIS Runtime content.
Add geodatabase content to your app
- Open the geodatabase using the Geodatabaseclass, which takes the path to the geodatabase in the class constructor. This class has methods that let you list the feature tables and properties in the geodatabase file.
m_geodatabase = new EsriRuntimeQt::Geodatabase("/path_to_my_geodatabase/mydata.geodatabase", this);
- A feature layer is used to display features on a map. To create a feature layer from a geodatabase, first, use the geodatabase to retrieve a feature table, and next, create a feature layer from that feature table. The geodatabase potentially contains several geodatabase feature tables, depending on the layers you requested during geodatabase generation. If the geodatabase was created from a sync-enabled feature service, you can retrieve a feature table by ID corresponding to the feature service's layer ID.
m_gdbFeaturetable = m_geodatabase->geodatabaseFeatureTables().at(0); m_featureLayer = new EsriRuntimeQt::FeatureLayer(m_gdbFeaturetable, this);
- Add the feature layer to the map. Once the layer is added and initialized, your features display in the map.
The features you will see in the map depend on the map extent displayed. If your features are not displaying, make sure you have panned or zoomed to the appropriate extent, and that the spatial reference of the geodatabase matches the spatial reference of the map. You can set the spatial reference of a geodatabase at generation time, as described in Generate a geodatabase from a feature service.
- When you are done with the geodatabase, for example, when closing the application, call delete on the geodatabase object. This ensures that file resources release and the database correctly closes.
Include a basemap
A basemap is a map layer that helps orient the user of the map. Typically it sits behind operational layers and shows roads and buildings to give context to the operational layer.
Create a basemap from a tiled service (download a basemap)
An offline copy of tiled map services can be requested so that a basemap is available when the application is working in an offline environment. These copies can be downloaded in the form of a tile package (.tpk file) or compact cache by using the API's ExportTileCacheTaskclass. 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:
- Tile cache type, that is, tile package or compact cache
- How the levels of detail (also known as LODs) for the tile cache should be specified, that is, using level IDs, scales, or resolutions
- Levels, scales, or resolutions for the tile cache
- Extent of the tile cache (this can be a polygon geometry, not just an envelope)
- Spatial reference for the tile cache
For a list of ArcGIS Online basemaps that you can take offline, see Tiled Basemaps.
When creating an offline tile cache from a tiled service, consider the following:
- The exportTiles operation used to generate tile caches is only available on ArcGIS 10.2.1 for Server or later 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. Try generating a smaller tile cache to get an idea of how long caching will take when planning a large offline data capture event.
- When generating a tile cache from an ArcGIS Online basemap, there is a cap on the number of tiles you can download in one request, which is 100,000 tiles. Read more on this in the exportTiles REST documentation.
- Organizations that use their own ArcGIS Server to host offline tile caching can configure the ArcGIS Server's maxExportTilesCount via the admin to change the default 100,000-cache tile cap.
Tile package or compact cache?
Tile packages are the most convenient because the entire cache lives in a single .tpk file. However, the size of this file might not be compatible with devices such as Android-based machines, as there is a limit on the maximum file size. If this is an issue, use compact caches instead. Compact caches store the same information as tile packages, but the data is stored in a structure of directories and files that are more suitable for some operating systems.
Create a basemap using ArcGIS for Desktop
When you create a basemap using ArcGIS for Desktop, you can set the format, tiling schemes, and levels of detail. For details, see the online ArcGIS help topics How to create a tile package and About tile packages.