The preplanned workflow allows an organization to prepare offline maps so that they can be taken into the field, as required. The map author creates a map area defined by a specific geographical area of work. This process generates the associated map, tile package, and geodatabase files and stores them in a mobile map package. The offline map resides in this mobile map package, in ArcGIS Online or ArcGIS Enterprise, until the field worker downloads it. As soon as the mobile map package is downloaded, the field worker can disconnect their device and work with the map offline.
The main advantages of this workflow are as follows:
- The map author can organize and define very specific map areas for the field workers.
- The user can obtain the preplanned map area more quickly because the mobile map package has been generated, in advance, by the author. In contrast, during the on-demand workflow, the user has to both generate and download the mobile map package to their device.
- Many users can download exactly the same mobile map package.
Create preplanned map areas
The preplanned workflow allows you to create a mobile map package, in advance, so that it can be downloaded by field workers when they need it. To do this, create a map area within a web map and generate the mobile map package for the map area.
To create preplanned map areas, you must use web maps created with ArcGIS or with ArcGIS Enterprise 10.6.1 or later. You must ensure that all services used in the web map are enabled for offline use.
You can create map areas manually using the ArcGIS Online or ArcGIS Enterprise user interface, or programmatically, using Python scripts or the ArcGIS REST API, as follows:
ArcGIS Online or ArcGIS Enterprise
Manually create, edit, and manage map areas as follows:
If a map area was created with a version earlier than 10.6.1, you can take it offline. If you want to edit the map area, you must re-create it with ArcGIS Portal 10.6.1 or later.
Use the ArcGIS API for Python to write python scripts to create map areas and generate their associated data packages. This is detailed in the managing map areas Python topic along with other useful map area management functions such as the following:
- Update a map area and any of its packages that have been deleted or contain newer data.
- Delete an individual data package.
- Delete a map area along with its associated packages.
- Inspect any of the map area's packages.
- List the web map's current map areas.
It is recommended that you use ArcGIS API for Python 1.7 or later.
ArcGIS Rest API
Use the ArcGIS REST API if you need even more control when creating your preplanned map areas. There are two stages to this process:
- To create a map area, you must run the Create Map Area task, providing a bookmark or geographical extent as the area of interest. Upon completion, the task will generate a new portal item of type MapArea. This task requires that the web map is enabled for offline use. It is only available to the owner of the web map and organization administrators.
- To create the data defined by the map area, you must run the Setup Map Area task, providing the map area portal item ID. This will create a set of data files such as tile packages, vector tile packages, and SQLite geodatabases. For good data management, it is strongly recommended that you also provide a folder to organize these files. This task is only available to the map area portal item owner and organization administrators.
You must use ArcGIS REST API 10.6.1 or later.
In addition to creating the map area, you can also define how users receive updates to the geodatabases in the offline map. Updates can happen by synchronizing the offline map's geodatabases with their online services or by applying scheduled update files to the geodatabases (read-only).
- Synchronization allows you to download updates from the online service and upload edits from the offline map, once connectivity is restored. You can configure this synchronization direction to determine in which direction edits are synchronized—download only, upload only, or bi-directional.
- Apply scheduled updates allows you to schedule the regular creation of a file containing updates made to the feature service. The ArcGIS Runtine API can download the files it requires and apply them to the offline map's geodatabases. These files are relatively small so they are quick to download and fast to apply. This is a scalable solution for receiving updates to read-only geodatabases. This option is useful in cases in which you need to provide many clients with an up-to-date read-only copy of the feature data. You can set the scheduled update parameters using the Setup Map Area task in the ArcGIS REST API. Applying these updates will be described in Update an offline map.
Scheduled updates are supported with feature services created using ArcGIS Online or ArcGIS Enterprise 10.7.1 or later. Therefore, you must use ArcGIS REST API 10.7.1 or later.
Once you have created the preplanned map areas, they will be ready to download to your device. The following section describes how you build a Runtime app to download the map area.
Identify a map area
As discussed above, each web map can contain one or more preplanned map areas. Your app needs to determine which map area should be downloaded. You can do this by allowing the field worker to select a map area from a map view or from a list of map areas. Alternatively, the app logic could select a map area for the field worker.
Follow these steps to retrieve all of the map areas:
- Instantiate the offline map task by passing either a map (created from a web map) or a web map's portal item to the OfflineMapTask constructor.
- Retrieve a list of the preplanned map areas from the web map using the getPreplannedMapAreas method on the OfflineMapTask.
- Load the preplanned map area; PreplannedMapArea.
- Display the map area titles and thumbnails in a list, or show the map area extents or just select a map area by name.
Create the parameters
To take a map offline you can provide a set of DownloadPreplannedOfflineMapParameters. To obtain a set of default parameters pass in the map area to the createDefaultDownloadPreplannedOfflineMapParameters method on the OfflineMapTask. The value of these default parameters will match the advanced offline settings configured by the web map author (discussed in Take web maps offline.
For more information see Advanced parameters.
Create the job
Create the download preplanned map area job by calling the downloadPreplannedOfflineMapJob method on the OfflineMapTask. Pass in the PreplannedMapArea and a download directory on the device. If this download directory already exists it must be empty. If the directory doesn't exist, it will be created by the job.
If, however, you have created parameters to control the map content you must create the DownloadPreplannedOfflineMapJob using the downloadPreplannedOfflineMapJob method on the OfflineMapTask and provide both the DownloadPreplannedOfflineMapParameters and the download directory.
Run the job
To download the preplanned map area to your device start the DownloadPreplannedOfflineMapJob. Upon completion the job will return an instance of the DownloadPreplannedOfflineMapResult. If at least one table or layer failed to be taken offline the hasErrors property will be true. In this case you should examine the layerErrors and tableErrors dictionaries to identify the problem.
Remember that if the job's ContinueOnErrors parameter has been set to false then the job will be terminated immediately if a single layer or table fails to be taken offline.
If you want to display the map immediately then use the DownloadPreplannedOfflineMapResult.offlineMap.
Note:Note that the job will behave the same whether it was created with or without the DownloadPreplannedOfflineMapParameters.
For more details on how to work with jobs, see the Tasks and jobs topic.
Offline maps created by the preplanned workflow are stored in an unpacked mobile map package. When your app goes into the field you will need to open the map directly from the mobile map package downloadDirectory stored on your device. See Open an offline map for more information.
Once you have the default parameters you can customize them as required. For example:
- Continue if a table or layer fails?
The DownloadPreplannedOfflineMapJob takes a map's tables and layers offline. By default this job will continue to do this even if one table of layer has failed. Failures could be due to an intermittent network connection, loss of the service or an unsupported layer type. The approach ensures that you can take a map offline but you may have some data missing.
To ensure that the offline map contains all of its layers and tables you can request that the job is stopped if any layer or table fails to download. To do this set the ContinueOnErrors property to false.
- Which basemap should the map use?
The author of the web map can define whether the map uses:
- The basemap defined by the web map
This is the default situation and ensures that a tile package is downloaded as part of the mobile map package.
- A tile package that is already on the device
The tile package must be downloaded or copied onto the device and can be located using an actual file path on the device or a path that is relative to the mobile map package. You must ensure that the tile package covers the areas required by your map area. The benefits of this option are that the mobile map package file will be smaller, the download time may be faster, and you can use the tile package in many different maps and apps.
To use the tile package on your device you must set the referenceBasemapDirectory to the directory which contains the tile package. It is recommended that you confirm that the tile package file, referenceBasemapFilename, exists on the device before running the AGSDownloadPreplannedOfflineMapJob. This job will add the tile package, as a basemap, to the offline map.
If this tile package has a different spatial reference to your online map then the offline map will use the spatial of the tile package.
- No basemap
If you only want to take the operational layers offline you can programmatically exclude the basemap. To do this set the includeBasemap property to false. In this case the DownloadPreplannedOfflineMapJob will not download layers included as part of the map's basemap. This task will not use the local tile package, even if you have specified one.
- The basemap defined by the web map
- Overwrite the geodatabase update mode?
If the web map author has specified that scheduled updates will be generated for all feature services in the map (discussed in Define updates, then the updateMode on the DownloadPreplannedOfflineMapParameters will be set to PreplannedUpdateModeDownloadScheduledUpdates. This means that the geodatabases will be read-only and can only receive updates via the scheduled update files.
If you want to edit these geodatabases and adopt the synchronization approach you can override this updateMode by setting it to PreplannedUpdateModeSyncWithFeatureServices. From this point you will not be able to update the geodatabase using the scheduled update files.
Instead of obtaining the default set of DownloadPreplannedOfflineMapParameters you could construct them manually. The author of the web map can recommended how data is downloaded to offline devices, and subsequently synchronized, by adjusting the map's advanced offline settings (discussed in Take web maps offline). You can access these advanced settings from the map's OfflineSettings. They include:
- working with feature attachments
- synchronizing edits
- downloading a basemap or using one which is already on the device
Once you have obtained the offline map follow these steps:
- Display and interact with the maps, layers and data offline. Explore and edit the feature data, if necessary.
- Update an offline map by synchronizing your edits with the online services, when connectivity is restored.
- Finish using an offline map by unregistering any geodatabases and fully releasing all locks on the mobile map package.