Use one of the ArcGIS Maps SDKs for Native Apps to load the mobile map package and build an offline application.
Prerequisites
- You need ArcGIS Pro.
- You need an ArcGIS Online or ArcGIS Enterprise account.
- You need to complete Step 2. Create a mobile map package or download its solution.
Setup offline app
In this step, choose the appropriate ArcGIS Maps SDK for Native Apps and set up your development environment.
-
Install and setup the ArcGIS Maps SDK for .NET on your development machine. Make sure you fulfill the SDK's system requirements.
-
Go to the Display a map tutorial and download the completed solution to get a starter code for this workflow.
You do not need to create another API key credential. -
Open the
.slnfile 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.A Map -
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
Mapclass, double-click the namespace name (View Model Display) to select it, and then right-click and choose Rename....A Map - 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).
Add a mobile map package to the project
Add the mobile map package to your project so the app can load it from a bundled file or a local path.
You will add a mobile map package (MMPK)
-
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:
Display map from the mobile map package
Create a function that loads the mobile map package and displays its first map in the map view.
-
In the Visual Studio > Solution Explorer, double-click MapViewModel.cs to open the file.
-
Add additional required
usingstatements at the top of the class.MapViewModel.csUse dark colors for code blocks 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
Setupfunction.Map() -
Modify the signature of the
Setupfunction to include theMap() asynckeyword and to returnTaskrather thanvoid.MapViewModel.csUse dark colors for code blocks Copy private async Task SetupMap() { }When calling methods asynchronously inside a function (using the
awaitkeyword), theasynckeyword is required in the signature.Although a
voidreturn type would continue to work, this is not considered best practice. Exceptions thrown by anasync voidmethod 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 voidis 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() Mapconstructor) to avoid a compilation warning. After changingView Model Setupto 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 Copy 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
Setupfunction. This code defines the path to the mobile map package relative to the app, creates the mobile map package using theMap() Mobileconstructor, loads the mobile map package asynchronously, and adds the first map in the mobile map package to theMap Package Map.View Use dark colors for code blocks // 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
Mobilecan contain many maps in aMap Package Mapsarray.Loading the mobile map package
A mobile map package (MMPK) is a standalone file that contains one or more map definitions, including the basemap layers, data layers, layer styles, and pop-up styles for use in offline applications built with ArcGIS Maps SDKs for Native Apps. 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.
Congratulations!
You have completed the Create and display a mobile map package how-to. The application uses the ArcGIS Maps SDKs for Native Apps to load and display a mobile map package (.mmpk) created in ArcGIS Pro
What's next?
To explore additional ArcGIS offline capabilities, go to Tutorials for more how-tos, tutorials, and samples.

Honor mobile map package expiration date

Find route in mobile map package
Display maps and use locators to enable search and routing offline using a mobile map package.

Display scene from mobile scene package
Display a scene from a mobile scene package.