You can obtain an offline map using any of these workflows:
If you created the mobile map package with ArcGIS Pro you may need to consider:
If not then proceed to Open the offline map
Unpack a mobile map package
With ArcGIS Pro version 2.1 (or higher) you can include raster datasets in a mobile map package. If this has happened then you must unpack the mobile map package file into a directory before you load it into your app:
- Check if you can read the .mmpk file directly by examining the value of MobileMapPackageUtility.isDirectReadSupported.
- If you cannot read the .mmpk file directly then use the unpack method to place the contents of the .mmpk file into a directory.
- Instantiate the mobile map package using the directory location.
Unpacking a mobile map package file into a directory obviously occupies space. You may want to confirm that the device has sufficient space before you unpack the mobile map package file to avoid an unpacking error. To save space you could delete the original mobile map package file after unpacking completes (unless you need this file for another purpose).
Further advice regarding unpacking a mobile map package:
- If you try to load a mobile map package where direct read is not supported an error will be thrown. The error message will advise you to unpack the mobile map package file.
- Instead of adding raster data to a scene as an operational or basemap layer you could create a .tpk from raster data and add that to the map before creating the mobile map package. This would avoid the need to unpack the mobile map package.
- An unpackaged mobile map package takes roughly the same amount of space as the original file.
- You should confirm that the device has sufficient space before you unpack the mobile map package to avoid an unpacking error.
- You could delete the original mobile map package file after unpacking completes to save space (unless you need to retain this file for another purpose).
Expired mobile map packages
With ArcGIS Pro 2.4 (or later) you can set an expiration date on your mobile map package using some options provided by the ArcGIS Publisher extension. Expiration gives you more control over the lifetime of your data. For example, it will allow you to:
- Provide data to 3rd party contractors which will expire at the end of a contract.
- Indicate to your users that frequently changing data has become obsolete.
As an ArcGIS Runtime developer there are three possible outcomes when you try to load a mobile map package.
- You can access the mobile map package. This situation occurs if the mobile map package has not expired or if it has been created without an expiration.
- You can access 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 MobileMapPackage::load()MobileMapPackage.load(). No extra workflow or code-paths are required to accommodate these.
You can, however, retrieve the expiration details from the expiration property on the MobileMapPackage if you want to provide your users with extra information. For example, you could display how many days remain before the mobile map package expires:
- 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 expiry date.
- Calculate the number of days between today and the expiry date. Report the number of days remaining.
Open the offline map
When your app goes into the field you will need to open the map directly from the mobile map package directory or file stored on your device. To create the mobile map package object, pass the mobile map package directory or file path to the MobileMapPackage constructor.
Upon loading the offline map, its metadata is accessible using the Map.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 MobileMapPackage.item property.
See Display a map for more details on how to access and display maps stored in mobile map packages.
After you have loaded and opened the mobile map package you can continue to work with the maps and 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 to unregistered any geodatabases and fully release all locks on the mobile map package.