Open a map offline
You can open any map while offline if it was created by any of the following workflows:
- Take a map offline with ArcGIS Pro — Provides a mobile map package file (
- Preplanned — Downloads an offline map which is stored as a mobile map package directory.
- On-demand — Downloads an offline map which is stored a mobile map package directory.
If you created a mobile map package file with ArcGIS Pro, you may need to consider whether the mobile map package content has expired. If not, proceed to open the map.
Using ArcGIS Pro 2.4 (or later), you can control the lifetime of your maps by setting an expiration date on your mobile map package. This will allow you to do the following:
- Provide data to third-party contractors that will expire at the end of a contract.
- Indicate to your users that the data has become obsolete.
When you use the ArcGIS Pro tool to create the mobile map package, you can set an expiration date and time, an expiration message, and access options if the package has expired.
As an ArcGIS Runtime developer, there are three possible outcomes when you try to load a mobile map package:
- You have full access to the mobile map package. This situation occurs if the mobile map package has not expired or if it has been created without any expiration properties.
- You have full access to the mobile map package even though the maps and their data have expired. You will be warned that the mobile map package is out of date.
- You cannot access the mobile map package because it has expired. In this case, the mobile map package will fail to load and you will not be able to access its maps and data.
These three outcomes are managed by the mobile map package load process. No extra workflow or code paths are required to accommodate this expiration.
If you want to provide your users with extra information, you can retrieve the expiration details from the mobile map package. For example, you can display how many days remain before the mobile map package expires. To do this, perform the following steps:
- Load the mobile map package.
- Read the expiration property on the mobile map package.
- Confirm that the mobile map package has not expired.
- Get the expiration date.
- Calculate the number of days between today and the expiration date. Report the number of days remaining.
You can open the map directly from a mobile map package file (created by ArcGIS Pro or from a mobile map package directory (downloaded with the preplanned or on-demand workflows).
To create the mobile map package object, pass the mobile map package file path or directory to the
AGSMobileMapPackage constructor. Load the mobile map package and access its collection of maps. Assigning the
AGSMap to the
AGSMapView will initiate loading the map, its layers, and data.
After loading the map, its metadata is accessible using the
AGSMap.item property. In some situations, you may want to access the metadata from the mobile map package without loading the map itself. You can access this from the
After you have opened the map, you can display and interact with it, its layers, and data contents offline.
If you are using an offline map downloaded from the preplanned or on-demand workflow, you can also:
- Edit the feature data, if necessary.
- Update the offline map by synchronizing your edits with the online services when connectivity is restored.