Workflow: Create an app using a mobile map package

Create a mobile map package

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.

  1. In your web browser, go to the Santa Monica Parcels item.

  2. 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.

  1. Unzip the Santa Monica parcels zip file.
    • The zip file contains the Parcels_Public.shp file.
  2. Launch ArcGIS Pro.
    • Create a new map project.
    • A map with World Topographic Map and World Hillshade basemap layers will be created.
  3. 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

Set the feature styles

You can use ArcGIS Pro to change the visualization of the Santa Monica parcels layer.

  1. In the Content pane, right-click on the feature service and click Symbology.

  2. In the Symbology pane, set the following properties:

    • Primary symbology: Unique values
    • Field 1: useType
  3. In the Classes tab, click on the symbol for Commercial > Properties.

  4. Set the fill colors for each useType:

    • In the Appearance section, click the color button > Color Properties... to display the color palette. Set the following property:

      • HEX#: #c29ed7
      • Transparency: 30%
    • Repeat the above step for the following useTypes:

      • Fill Color:
        • Residential: #ffde3e
        • Industrial: #004c73
        • Government: #fc921f
        • Institutional: #149ece
        • Recreational: #267300
        • Miscellaneous: #b7814a
  5. Set the outline colors for each useType:

    • 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%
    • In the Appearance section, set the Outline width to 1.0 pt.
    • Repeat the above steps for each useType.

The styled layer will look something like this:

Santa monica parcels feature layer

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.

  1. In the Content pane, click on the Map layer.
  2. In the Map tab, click Basemap and choose Navigation.
  3. 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.

  1. In the main ribbon, click the Share tab and then Mobile Map.
  2. 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 SantaMonicaParcels.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.
  3. Click Package to create the mobile map package.

Your finished mobile map package should be saved as a file named SantaMonicaParcels.mmpk. The file should contain the Santa Monica map and parcels data.

2. Build the app

Setup offline app

  1. Install and setup the ArcGIS Maps SDK for .NET on your development machine. Make sure you fulfill the SDK's system requirements.

  2. Follow the Display a map tutorial or download the completed solution to get a starter code for this workflow.

  3. Open the .sln file in Visual Studio.

    The Visual Studio solution, project, and the namespace for all classes currently use the name DisplayAMap. 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.

  4. 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.
  5. 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 MapViewModel class, double-click the namespace name (DisplayAMap) to select it, and then right-click and choose Rename....
    • 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.
  6. Build the project.

    • Choose Build > Build solution (or press F6).

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.

  1. From the Visual Studio Project menu, choose Add > Existing item ....

  2. Navigate to the folder that contains your mobile map package. Change the file type in the dialog to All files (*.*), choose SantaMonicaParcels.mmpk, then click Add to add it to the project.

  3. In the Visual Studio Solution Explorer, select SantaMonicaParcels.mmpk. In the Properties window, set the following properties of the file.

    • Build Action: Content
    • Copy to Output Directory: Copy always

Display map from the mobile map package

  1. In the Visual Studio > Solution Explorer, double-click MapViewModel.cs to open the file.

  2. Add additional required using statements at the top of the class.

    MapViewModel.cs
    Use dark colors for code blocks
    14 15 16 17 18 19 20 21 22 23 24
    Add line.Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    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;
    
  3. In the MapViewModel class, remove all the existing code in the SetupMap() function.

  4. Modify the signature of the SetupMap() function to include the async keyword and to return Task rather than void.

    MapViewModel.cs
    Expand
    Use dark colors for code blocks
    58 59 60 61
    Change lineChange line
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
            private async Task SetupMap()
            {
    
            }
    
    Expand
  5. (Optional) Modify the call to SetupMap() (in the MapViewModel constructor) to avoid a compilation warning. After changing SetupMap() to an asynchronous method, the following warning appears in the Visual Studio Error List.

    Use dark colors for code blocksCopy
    1
    2
    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.cs
    Expand
    Use dark colors for code blocks
    33 34 35 36 37 38
    Change line
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
            public MapViewModel()
            {
    
                _ = SetupMap();
    
            }
    
    Expand
  6. Add the following code to the SetupMap() function. This code defines the path to the mobile map package relative to the app, creates the mobile map package using the MobileMapPackage constructor, loads the mobile map package asynchronously, and adds the first map in the mobile map package to the MapView.

    Expand
    Use dark colors for code blocks
    61 62 63 64 65 66 67 68 69 70 71
    Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.Add line.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
                // 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();
    
    Expand
  7. Click Debug > Start Debugging (or press F5 on the keyboard) to run the app.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.