If your users' devices need to operate in a disconnected or offline capacity, use an offline scene in your ArcGIS Runtime app.
For use in ArcGIS Runtime apps, offline scenes must be created in ArcGIS Pro and saved as mobile scene packages (.mspk files). For information on creating and saving .mspk files in ArcGIS Pro, see Create Mobile Scene Package in the ArcGIS Pro tool reference.
You can distribute .mspk files to your users, for use in your app, by:
Uploading and sharing the files in your organization (with ArcGIS Online or your portal)
Delivering the files to individual devices through common file sharing methods (network share, email, and so on)
Offline scenes can include basemaps, operational layers, 3D scene layers, tiled layers (.tpk), tables, relationship classes, locators and elevation sources as tiled data. Raster elevation sources are not supported.
Open an .mspk file in your app
Most mobile scene packages can be accessed directly by instantiating the AGSMobileScenePackage object from the .mspk file. However, raster data that's an operational or basemap layer cannot be read directly from an .mspk file, so it's recommended you always perform a check. To perform this check, follow the steps below.
- Make sure the .mspk file gets added to your users' devices. For example, you can have your users download it from ArcGIS Online or your portal to their device when connected.
- Check whether the mobile scene package file supports direct reading by calling the checkDirectReadSupportForMobileScenePackage method.
- If the file can be read directly, skip to step 5.
- If the file cannot be read directly, then unpack the .mspk file in an output directory. Before unpacking the file, confirm that the device has
sufficient space for the file using the device's native API. An unpacked .mspk file occupies a
similar amount of space as the original packaged file. After the unpacking operation completes, you can delete the original .mspk file to save space (unless you need the file for another purpose).
To avoid having to unpack the .mspk file, instead of adding raster data to an .mspk file as an operational or basemap layer, you can create a .tpk file from the raster data and add that to the scene before creating the .mspk file.
- Instantiate the AGSMobileScenePackage object from the .mspk file or output directory.
- Load the AGSMobileScenePackage.
Once you have instantiated and loaded the .mspk file, you can access any of its scenes for display.
- To display a scene, pass it to the scene view.