![Create a mobile map package](/documentation/static/c79c13a31c2c8ab6f5769cab9a76194d/4cdf7/create-an-app-that-displays-data-from-a-mobile-package.png)
In this workflow, you will learn how to create a feature layer, create an ArcGIS Pro project that shows a map of Santa Monica, California, add the layer into the map, export it as a mobile map package (.mmpk
) file, then sideload it into your device to create a fully offline app. You can also add 3D data into your ArcGIS Pro project and export it as a mobile scene package (.mspk
) file. However, this workflow will only show how to add a 2D map and export a mobile map package.
Prerequisites
You need an ArcGIS Pro installed and licensed for this tutorial. If you do not have access to ArcGIS Pro, you can start a 21 day free trial.
Steps
1. Prepare the map and data
Download dataset
For this workflow, you will use the Santa Monica Parcels dataset to create a hosted feature layer for your mobile map package.
-
In your web browser, go to the Santa Monica Parcels item.
-
Click the Download button to download the zip file locally.
Import dataset to create a feature layer
You can use ArcGIS Pro to import shapefile data.
- Unzip the Santa Monica parcels zip file.
- The zip file contains the Parcels_Public.shp file.
- Launch ArcGIS Pro.
- Create a new map project.
- A map with
World Topographic Map
andWorld Hillshade
basemap layers will be created.
- In the Map ribbon, click on Add Data > Data and select Parcels_Public.shp file.
The Parcels_Public.shp file is added as a feature layer to the map.
The feature layer will look something like this:
![Santa monica parcels feature layer](/documentation/static/5566285cf4aecf6d96301b3f982a56a1/4cdf7/default-parcels-styles-pro.png)
Set the feature styles
You can use ArcGIS Pro to change the visualization of the Santa Monica parcels layer.
-
In the Content pane, right-click on the feature service and click Symbology.
-
In the Symbology pane, set the following properties:
- Primary symbology:
Unique values
- Field 1:
use
Type
- Primary symbology:
-
In the Classes tab, click on the symbol for Commercial > Properties.
-
Set the fill colors for each
use
:Type -
In the Appearance section, click the color button > Color Properties... to display the color palette. Set the following property:
- HEX#:
#c29ed7
- Transparency:
30%
- HEX#:
-
Repeat the above step for the following
use
:Types - Fill Color:
- Residential:
#ffde3e
- Industrial:
#004c73
- Government:
#fc921f
- Institutional:
#149ece
- Recreational:
#267300
- Miscellaneous:
#b7814a
- Residential:
- Fill Color:
-
-
Set the outline colors for each
use
:Type - In the Appearance section, click the outline color button > Color Properties... to display the color palette. Set the following property for
Commercial
:- HEX#:
#ffffff
- Transparency:
65%
- HEX#:
- In the Appearance section, set the Outline width to
1.0 pt
. - Repeat the above steps for each
use
.Type
- In the Appearance section, click the outline color button > Color Properties... to display the color palette. Set the following property for
The styled layer will look something like this:
![Santa monica parcels feature layer](/documentation/static/ffe29d1596aede052e1daeead927e1ec/4cdf7/parcels-feature-layer-pro.png)
Set up the map in ArcGIS Pro
Now, you will combine the data layer in a map in ArcGIS Pro, ready to export as a mobile map package.
- In the Content pane, click on the Map layer.
- In the Map tab, click Basemap and choose Navigation.
- In the Map tab, click Locate and type
Santa Monica
in the search box and then hit the enter key. This will focus the map to the city of Santa Monica, California. Zoom in and out to explore your desired region to take offline.
Create the mobile map package file
The final step is to use a sharing tool in ArcGIS Pro to export the mobile map package. In this case you will clip the layers out that fall within the current visible extent of the map.
- In the main ribbon, click the Share tab and then Mobile Map.
- On the left side of the application in the Package Mobile Map window, set the following properties:
- Select Save package to file to saves a mobile map package
.mmpk
file to local storage. - Name: Click the folder to select a save location for the mobile map package. Name it
Santa
.Monica Parcels.mmpk - Summary: Parcels of the city of Santa Monica, California.
- Tags: Santa Monica, Parcels
- Check Current Display Extent. Ensure the map is zoomed to the area you want to package, e.g. Santa Monica.
- Select Save package to file to saves a mobile map package
- Click Package to create the mobile map package.
Your finished mobile map package should be saved as a file named Santa
. The file should contain the Santa Monica map and parcels data.
2. Build the app
Setup offline app
-
Install and setup the ArcGIS Maps SDK for .NET on your development machine. Make sure you fulfill the SDK's system requirements.
-
Follow the Display a map tutorial or download the completed solution to get a starter code for this workflow.
-
Open the
.sln
file in Visual Studio.The Visual Studio solution, project, and the namespace for all classes currently use the name
Display
. Follow the steps below if you prefer the name to reflect the current tutorial. These steps are not required, your code will still work if you keep the original name.AMap -
Update the name for the solution and the project.
- In Visual Studio, in the Solution Explorer, right-click the solution name and choose Rename. Provide the new name for your solution.
- In the Solution Explorer, right-click the project name and choose Rename. Provide the new name for your project.
-
Rename the namespace used by classes in the project.
- In the Solution Explorer, expand the project node.
- Double-click MapViewModel.cs in the Solution Explorer to open the file.
- In the
Map
class, double-click the namespace name (View Model Display
) to select it, and then right-click and choose Rename....AMap - Provide the new name for the namespace.
- Click Apply in the Rename: DisplayAMap window that appears in the upper-right of the code window. This will rename the namespace throughout your project.
-
Build the project.
- Choose Build > Build solution (or press F6).
-
Install and setup the ArcGIS Maps SDK for Kotlin on your development machine. Make sure you fulfill the SDK's system requirements.
-
Complete the Display a map tutorial. Or download and unzip the Display a map solution in a new folder.
-
Modify the old project for use in this new tutorial. Expand More info for instructions.
-
On your file system, delete the .idea folder, if present, at the top level of your project.
-
In the Android tool window, open app > res > values > strings.xml.
In the
<string name="app_
element, change the text content to a title that suits your app objective.name"> -
In the Android tool window, open Gradle Scripts > settings.gradle.kts.
Change the value of
root
to a title that suits your app objective.Project.name -
The UI theme composable in Display a map tutorial was
Display
. Rename the theme composable throughout the tutorial by refactoringAMap Theme Display
.AMap Theme Right-click the function name
Display
and select Refactor -> Rename. Replace the name with a name that suits your app objective.AMap Theme -
Click File > Sync Project with Gradle files. Android Studio will recognize your changes and create a new .idea folder.
-
-
Install and setup the ArcGIS Maps SDK for Swift on your development machine. Make sure you fulfill the SDK's system requirements.
-
Follow the Display a map tutorial or download the completed solution to get a starter code for this workflow.
-
Install and setup the ArcGIS Maps SDK for Qt on your development machine. Make sure you fulfill the SDK's system requirements.
-
Start Qt Creator.
-
Click File > New File or Project. Under Projects, select ArcGIS.
-
Select the ArcGIS Maps 200.4.0 Qt Quick C++ app project template (or a later version) and click Choose.
You may have several selections for the ArcGIS project type. Be sure to select ArcGIS Maps 200.4.0 Qt Quick C++ app (or a later version).
-
In the Project Location dialog, name your project something that fits your scenario, e.g. Display_an_offline_map. Click Next.
-
In the Define Build System dialog, select qmake for your build system. Click Next.
-
In the Define Project Details dialog, give this app a description or leave as is. Leave the rest of this dialog as is.
-
Leave the 3D project box unchecked. At the ArcGIS Online Basemap dropdown menu, select Streets. Then click Next.
-
On the Kit Selection dialog, check the kit(s) you previously set up when you installed the API. You should select a Desktop kit to run this tutorial. Then click Next.
-
At the Project Management dialog, the option to Add as a subproject to root project is only available if you have already created a root project. Ignore this dialog for this tutorial. Click Next.
Add a mobile map package to the project
You will add a mobile map package (MMPK) to your Visual Studio project. To get an .mmpk
file, you can complete the Prepare the map and data step or download its solution.
-
From the Visual Studio Project menu, choose Add > Existing item ....
-
Navigate to the folder that contains your mobile map package. Change the file type in the dialog to
All files (*.*)
, chooseSanta
, then click Add to add it to the project.Monica Parcels.mmpk -
In the Visual Studio Solution Explorer, select
Santa
. In the Properties window, set the following properties of the file.Monica Parcels.mmpk - Build Action:
Content
- Copy to Output Directory:
Copy always
- Build Action:
In Android API level 30, use of scoped storage is mandatory. You can no longer use adb push
or the Device Explorer to manually create the required path /sdcard/Android/data/com.example.app/files
, to which you will upload the mobile map package. Only the Android OS has the appropriate permissions to do so.
Consequently, this tutorial guides you through the following stages. (1) Build and install the app on a device first, allowing Android OS to create the folders on the device file system.(2) Upload the .mmpk
file to that path using Device Explorer. (3) Restart the installed app to display the map from the mobile map package.
You will add a mobile map package (MMPK) to your Xcode project. To get an .mmpk
file, you can complete the Prepare the map and data step or download its solution.
Once you have the mobile map package:
- In Xcode's app menu, click File > Add Files to "...".
- Navigate to and select the
.mmpk
file, e.g.Santa
.Monica Parcels.mmpk - Choose Options, select the Copy items if needed checkbox, and ensure the project target is selected in Add to targets. Click Add.
You will add a mobile map package (MMPK) to your Qt Creator project. To get an .mmpk
file, you can complete the Prepare the map and data step or download its solution.
- Copy the file
Santa
to a local path on your hard drive (for example:Monica Parcels.mmpk C:/tutorial_
). Make a note of this path as you will need supply it later.mmpk/Santa Monica Parcels.mmpk
Display map from the mobile map package
-
In the Visual Studio > Solution Explorer, double-click MapViewModel.cs to open the file.
-
Add additional required
using
statements at the top of the class.MapViewModel.csUse dark colors for code blocks Add line. Add line. using System; using System.Collections.Generic; using System.Text; using Esri.ArcGISRuntime.Geometry; using Esri.ArcGISRuntime.Mapping; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Linq; using System.Threading.Tasks;
-
In the MapViewModel class, remove all the existing code in the
Setup
function.Map() -
Modify the signature of the
Setup
function to include theMap() async
keyword and to returnTask
rather thanvoid
.MapViewModel.csUse dark colors for code blocks Change line Change line private async Task SetupMap() { }
When calling methods asynchronously inside a function (using the
await
keyword), theasync
keyword is required in the signature.Although a
void
return type would continue to work, this is not considered best practice. Exceptions thrown by anasync void
method cannot be caught outside of that method, are difficult to test, and can cause serious side effects if the caller is not expecting them to be asynchronous. The only circumstance whereasync void
is acceptable is when using an event handler, such as a button click.See the Microsoft documentation for more information about Asynchronous programming with async and await.
-
(Optional) Modify the call to
Setup
(in theMap() Map
constructor) to avoid a compilation warning. After changingView Model Setup
to an asynchronous method, the following warning appears in the Visual Studio Error List.Map() Use dark colors for code blocks Copy Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
Because your code does not anticipate a return value from this call, the warning can be ignored. Your code will run despite the warning. But if you want to be more specific about your intentions with this call and to address the warning, add the following code to store the return value in a discard.
MapViewModel.csUse dark colors for code blocks Change line public MapViewModel() { _ = SetupMap(); }
From the Microsoft documentation:
"[Discards] are placeholder variables that are intentionally unused in application code. Discards are equivalent to unassigned variables; they don't have a value. A discard communicates intent to the compiler and others that read your code: You intended to ignore the result of an expression."
-
Add the following code to the
Setup
function. This code defines the path to the mobile map package relative to the app, creates the mobile map package using theMap() Mobile
constructor, loads the mobile map package asynchronously, and adds the first map in the mobile map package to theM a p Package Map
.View Use dark colors for code blocks Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. // Define the path to the mobile map package. string pathToMobileMapPackage = System.IO.Path.Combine(Environment.CurrentDirectory, @"SantaMonicaParcels.mmpk"); // Instantiate a new mobile map package. MobileMapPackage santaMonicaParcels_MobileMapPackage = new MobileMapPackage(pathToMobileMapPackage); // Load the mobile map package. await santaMonicaParcels_MobileMapPackage.LoadAsync(); // Show the first map in the mobile map package. this.Map = santaMonicaParcels_MobileMapPackage.Maps.FirstOrDefault();
A
Mobile
can contain many maps in aM a p Package Maps
array.Loading the mobile map package is an asynchronous process. The file is read on a thread that does not block the UI.
-
Click Debug > Start Debugging (or press F5 on the keyboard) to run the app.
-
In the Android tool window, open app > kotlin+java > com.example.app > MainScreen.kt. Expand the code block below, and replace the existing import statements in your project with the imports needed for this tutorial.
MainScreen.ktUse dark colors for code blocks import com.arcgismaps.mapping.ArcGISMap import com.arcgismaps.mapping.BasemapStyle import com.arcgismaps.mapping.MobileMapPackage import com.arcgismaps.toolkit.geoviewcompose.MapView
-
Delete code from the Display a map tutorial that will not be used in this workflow.
Display a Map tutorialUse dark colors for code blocks @Composable fun MainScreen() { val map = remember { createMap() } Scaffold( topBar = { TopAppBar(title = { Text(text = stringResource(id = R.string.app_name)) }) } ) { MapView( modifier = Modifier.fillMaxSize().padding(it), arcGISMap = map ) } } fun createMap(): ArcGISMap { return ArcGISMap(BasemapStyle.ArcGISTopographic).apply { initialViewpoint = Viewpoint( latitude = 34.0270, longitude = -118.8050, scale = 72000.0 ) } }
-
In the Android tool window, open app > res > values > strings.xml. Change the value of the
app_
string toname App using a mobile map package
. -
Create a
Map
class. Inside it, create properties and anView Model init
block as shown in the code below.The
init
block shows a warning message if you have not uploaded the mobile map package to your device file system.map
, which is initialized using theby
keyword and a mutable state ofArcGISMap
.context
for the application context.mobile
, which is the path where the downloaded map will be stored on the file system of your device. It is a string.M a p Package Local Path TAG
to pass to the logging functions.
MapViewModelUse dark colors for code blocks class MapViewModel( private val application: Application, private val coroutineScope: CoroutineScope, ): AndroidViewModel(application) { var map by mutableStateOf(ArcGISMap(BasemapStyle.ArcGISTopographic)) val context = application.applicationContext val mobileMapPackageLocalPath by lazy { // Get the path that will hold the mobile map package. context.getExternalFilesDir(null)?.path + File.separator + getString( context, R.string.santa_monica_parcels_webmap_offline_mmpk ) } private val TAG = this.javaClass.name }
-
In
Main
, create variables as shown below.Screen application
holds the application context.coroutine
provides a single coroutine scope for launching new coroutines.Scope map
instantiates theView Model Map
class.View Model
MainScreenUse dark colors for code blocks @Composable fun MainScreen() { val application = LocalContext.current.applicationContext as Application val coroutineScope = rememberCoroutineScope() val mapViewModel = remember { MapViewModel(application, coroutineScope) } }
-
In
Main
, callScreen Scaffold
, passing a top bar that displays the name of the app. Inside the content block, callColumn
, which will hold the map view and a button.MainScreenUse dark colors for code blocks @Composable fun MainScreen() { val application = LocalContext.current.applicationContext as Application val coroutineScope = rememberCoroutineScope() val mapViewModel = remember { MapViewModel(application, coroutineScope) } Scaffold( topBar = { TopAppBar(title = { Text(text = stringResource(id = R.string.app_name)) }) } ) { Column( modifier = Modifier .fillMaxSize() .padding(it) ) { } } }
-
Inside the content block for
Column
, callMap
and pass in the map from the map view model.View MainScreenUse dark colors for code blocks Scaffold( topBar = { TopAppBar(title = { Text(text = stringResource(id = R.string.app_name)) }) } ) { Column( modifier = Modifier .fillMaxSize() .padding(it) ) { MapView( modifier = Modifier .fillMaxSize() .weight(1f), arcGISMap = mapViewModel.map ) } }
-
Add a button, providing a callback function as the
o
parameter. The callback invokesn Click display
in the map view model.M a p From Mobile M a p Package() MainScreenUse dark colors for code blocks MapView( modifier = Modifier .fillMaxSize() .weight(1f), arcGISMap = mapViewModel.map ) Button( onClick = { coroutineScope.launch { mapViewModel.displayMapFromMobileMapPackage() } } ) { Text(text = "Display map from mmpk") }
-
In the
Map
class, create a suspend function namedView Model download
. Inside the function, do the following.Offline M a p Area() - Create a
Mobile
instance, providing the path to the mobile map package on your device file sytem.M a p Package - Load the mobile map package.
- If the load succeeded, get the first map stored in the mobile map package and assign it to the map variable. If the load failed, display an error message.
MapViewModelUse dark colors for code blocks suspend fun displayMapFromMobileMapPackage() { // Load the mobile map package val mapPackage = MobileMapPackage(mobileMapPackageLocalPath) mapPackage.load().onSuccess { map = mapPackage.maps.first() }.onFailure { error -> showMessage(context, "Failed to load mobile map package: ${error.message}") } }
- Create a
-
(Optional) The code in this workflow displays messages to the user and logs activity in Logcat. Here is a possible implementation.
MainScreenUse dark colors for code blocks private fun showMessage(context: Context, message: String) { Toast.makeText(context, message, Toast.LENGTH_LONG).show() Log.i(TAG, message) }
-
Click Run > Run > app to run the app.
Your app will be built and installed on the Android Virtual Device (AVD) that is currently selected in the Android Studio toolbar. On the AVD, you should see the title App using a mobile map package, an ArcGIS Topographic map zoomed out to world view, and a brief Toast telling you to upload the mobile map package file to your device.
For this first run, the Display map from mmpk button will be disabled.
Add mobile map package to device and run app again
-
Add the mobile map package (MMPK) to your device. To get an
.mmpk
file, you can complete the Prepare the map and data step or download its solution. -
In Android Studio, verify that your Android Virtual Device (AVD) is still connected. If it is not, expand More info below.
If you already closed the AVD on which you installed your app, then launch the Android Emulator manually.
- Click Tools > AVD Manager. In the Android Virtual Device Manager, double-click on the AVD you used before.
-
Display the Device Explorer tool window, which shows the file system on your AVD. Click View > Tool Windows > Device Explorer and wait until Device Manager connects to your AVD and shows the file system tree.
-
Upload the SantaMonicaParcels.mmpk file from your development computer.
-
In Device Explorer, right-click on the sdcard > Android > data directory and click Synchronize.
-
Right-click on sdcard > Android > data > com.example.app > files and click Upload. Navigate to the SantaMonicaParcels.mmpk file on your development computer. Then click OK.
-
-
Shut down the app running on your AVD.
-
Run the app a second time by clicking Run > Run > app.
The Display map from mmpk button is now enabled. Click it to display the first map from the mobile map package.
-
In Xcode, in the Project Navigator, click ContentView.swift.
-
Update the map variable to initialize a simple map object. Setting a basemap and initial viewpoint is not needed in this scenario.
ContentView.swiftUse dark colors for code blocks Change line struct ContentView: View { @State private var map = Map() private func loadMobileMapPackage() async throws { } var body: some View { MapView(map: map) } }
-
Create a function called
load
to set theMobile M a p Package() Mobile
referencing the mobile map package you added to the project.M a p Package The file name must match exactly. The name reflects the
Santa
added to the bundle.Monica Trails.mmpk If you sideload or download the
.mmpk
file, you should provide the full file URL to the file's location on the device.ContentView.swiftUse dark colors for code blocks Add line. Add line. struct ContentView: View { @State private var map = Map() private func loadMobileMapPackage() async throws { guard let mobileMapPackage = MobileMapPackage(name: "SantaMonicaParcels", bundle: .main) else { return } } }
-
Load the
Mobile
and check that it loads without error. Set the first map in the package to theM a p Package @State
map.An
Mobile
can contain many maps in aM a p Package maps
array.Loading the mobile map package is an asynchronous process. The file is read on a thread that does not block the UI.
ContentView.swiftUse dark colors for code blocks Add line. Add line. guard let mobileMapPackage = MobileMapPackage(name: "SantaMonicaParcels", bundle: .main) else { return } try await mobileMapPackage.load() guard let map = mobileMapPackage.maps.first else { return }
-
Lastly, as the
Map
is being built, use theView .task
view modifier to asynchronously call theload
.Mobile M a p Package() ContentView.swiftUse dark colors for code blocks Add line. Add line. Add line. Add line. Add line. Add line. Add line. var body: some View { MapView(map: map) .task { do { try await loadMobileMapPackage() } catch { print(error) } } }
-
Press Command + R to run the app.
-
In the Edit tab, double-click Headers > Display_an_mmpk.h to open the file. Remove the code that forward declares the
Map
class. This is no longer needed because the mobile map package (MMPK) will contain the map.Display_an_mmpk.hUse dark colors for code blocks Remove line #ifndef DISPLAY_AN_MMPK_H #define DISPLAY_AN_MMPK_H namespace Esri::ArcGISRuntime { class Map;
-
Remove the code that creates the
Map
pointer variablem_
.map Display_an_mmpk.hUse dark colors for code blocks Remove line private: Esri::ArcGISRuntime::MapQuickView* mapView() const; void setMapView(Esri::ArcGISRuntime::MapQuickView* mapView); Esri::ArcGISRuntime::Map* m_map = nullptr;
-
In the Edit tab, double-click Sources > Display_an_mmpk.cpp to open the file. Remove the lines
#include "Map.h"
and#include "Map
.Types.h" Display_an_mmpk.cppUse dark colors for code blocks Remove line Remove line #include "Display_an_mmpk.h" #include "Map.h" #include "MapTypes.h" #include "MapQuickView.h"
-
Remove the comma after
QObject(parent)
and then modify the constructor to remove initialization withBasemap
and theStyle Map
. (Note that theBasemap
configured for your project may be different than that shown here.)Style Display_an_mmpk.cppUse dark colors for code blocks Change line Remove line using namespace Esri::ArcGISRuntime; Display_an_mmpk::Display_an_mmpk(QObject* parent /* = nullptr */): QObject(parent), m_map(new Map(BasemapStyle::ArcGISStreets, this))
-
Remove the line of code that assigns the variable
m_
tomap m_
.map View Display_an_mmpk.cppUse dark colors for code blocks Remove line // Set the view (created in QML) void Display_a_map::setMapView(MapQuickView* mapView) { if (!mapView || mapView == m_mapView) { return; } m_mapView = mapView; m_mapView->setMap(m_map);
-
Under
private
, declare the new function you will implement to load the mobile map package. Then save and close the file.Display_an_mmpk.hUse dark colors for code blocks Add line. private: Esri::ArcGISRuntime::MapQuickView* mapView() const; void setMapView(Esri::ArcGISRuntime::MapQuickView* mapView); void setupMapFromMmpk();
-
Add
#include
statements for theMobile
andM a p Package Error
classes.Display_an_mmpk.cppUse dark colors for code blocks Add line. Add line. #include "Display_an_mmpk.h" #include "MapQuickView.h" #include "MobileMapPackage.h" #include "Error.h"
-
Add a call to a function that reads the map from the mobile map package. You will implement this function in the next step.
Display_an_mmpk.cppUse dark colors for code blocks Add line. // Set the view (created in QML) void Display_an_mmpk::setMapView(MapQuickView* mapView) { if (!mapView || mapView == m_mapView) { return; } m_mapView = mapView; setupMapFromMmpk(); emit mapViewChanged();
-
Add code to implement
setup
. This function defines the path to the MMPK file, instantiates the mobile map package using theM a p From Mmpk() Mobile
constructor, loads the mobile map package, and once loaded, sets the first map in the mobile map package to theM a p Package Map
. This also checks that the MMPK file was loaded correctly.View Display_an_mmpk.cppUse dark colors for code blocks Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. Add line. setupMapFromMmpk(); emit mapViewChanged(); } void Display_an_mmpk::setupMapFromMmpk() { // Instantiate a MobileMapPackage object and establish the path to the MMPK file. MobileMapPackage* m_mobileMapPackage = new MobileMapPackage( "<PATH_TO_MMPK_FILE>/SantaMonicaParcels.mmpk", this); // Use connect to signal when the package is done loading so that m_mapView can be // set to the first map (0). Check that the mmpk file has loaded correctly. connect(m_mobileMapPackage, &MobileMapPackage::doneLoading, this, [m_mobileMapPackage, this](Error error) { // Check that the mmpk file has loaded correctly if (!error.isEmpty()) { qDebug() << "Error:" << error.message()<< error.additionalMessage(); return; } // Get the first map in the list of maps, and set the map on the map view to display. // This could be set to any map in the list. m_mapView->setMap(m_mobileMapPackage->maps().at(0)); }); m_mobileMapPackage->load(); }
A MobileMapPackage can contain many maps in a
Maps
list. Loading the mobile map package is an asynchronous process. The file is read on a thread that does not block the UI. -
Press Ctrl + R to run the app.