Skip To Content ArcGIS for Developers Sign In Dashboard


You will learn: how to build an app that loads a basemap and feature layers from a mobile map package file.

Offline maps allow users to load basemaps and layers when their network connectivity is poor or offline. Mobile map packages (.mmpk files) can be created in ArcGIS Pro and loaded in your app with the MobileMapPackage class.

A mobile map package is a transport mechanism for maps, their layers, and the layer's data. It contains metadata about the package (description, thumbnail, and others), one or more maps, layers, data, and optionally networks and locators.

In this tutorial you will learn how to load a mobile map package and then use it in your app.

Before you begin

You must have previously installed the ArcGIS Runtime SDK for Qt and set up the development environment for your operating system.

Open the starter app project

If you have already completed the Create a starter app tutorial, start Qt Creator and open your starter app project. Otherwise, download and unzip the starter app project solution, and then open it in Qt Creator.

Prepare your data

You will need a mobile map package (.mmpk) file to complete this tutorial. Learn how to create mobile map packages in the Prepare your data for offline use tutorial. Alternatively, download the map package we prepared, and save the file on your development machine.


Save the path of the mobile map package

  1. Recall the absolute path of the mobile map package file you prepared in the prior step. The path /your_local_path/offline-maps-package.mmpk is a placeholder in the code below. Change this to match your file system.

Import headers and declare member variables

  1. In Projects, double click on Headers > Create_a_starter_app.h, forward declare MobileMapPackage by adding class MobileMapPackage; to the namespace along with an additional include statement.

    class MapQuickView;
    // *** ADD ***
    class MobileMapPackage;
    #include <QObject>
    // *** ADD ***
    #include <QString>
  2. Add the public member function openMapPackage. This function will asynchronously open the map package and set it on the map view.

      explicit Create_a_starter_app(QObject* parent = nullptr);
      ~Create_a_starter_app() override;
      // *** ADD ***
      void openMapPackage(const QString& dataPath);
  3. Add the private member variable m_mmpk to hold a reference to the map package.

      Esri::ArcGISRuntime::MapQuickView* m_mapView = nullptr;
      // *** ADD ***
      Esri::ArcGISRuntime::MobileMapPackage* m_mmpk = nullptr;

Load the mobile map package

  1. In Projects, double click on Sources > Create_a_starter_app.cpp to open it in the editor. Comment out #include "Basemap.h" because the map package will include the basemap definition. Add an include for MobileMapPackage so that you can reference the class in your code.

    // *** UPDATE ***
    // #include "Basemap.h"
    #include "Map.h"
    // *** ADD ***
    #include "MobileMapPackage.h"
  2. You are displaying an offline map package, and Basemap is an online service. Accordingly, update the constructor to remove m_map from the initializer list in the constructor. Also remove the center and viewpoint objects and replace the body of the constructor with following code to open the map package.

    Create_a_starter_app::Create_a_starter_app(QObject* parent /* = nullptr */):
       // *** UPDATE ***
       // QObject(parent),
       // m_map(new Map(Basemap::topographicVector(this), this))
      // *** UPDATE ***
      // const Point center(-118.71511, 34.09042, SpatialReference::wgs84());
      // const Viewpoint viewpoint(center, 300000.0);
      // set the path below to your local path to this file
      const QString mmpk_path("/your_local_path/offline-maps-package.mmpk");
  3. Add the public member function openMapPackage to open a MobileMapPackage and wait until it loads to add it to the map view.

    void Create_a_starter_app::openMapPackage(const QString& dataPath)
        m_mmpk = new MobileMapPackage(dataPath, this);
        connect(m_mmpk, &MobileMapPackage::doneLoading, this, [this](Error e) {
            if (!e.isEmpty())
                qDebug() << QString("Error loading package: %1 %2").arg(e.message(), e.additionalMessage());
            if (!m_mmpk || !m_mapView || m_mmpk->maps().isEmpty())
  4. Run your code to load the offline map.

Congratulations, you're done!

Your map, as it was designed in ArcGIS Pro, should load and display with the view point centered on the Santa Monica Mountains. Compare your map with our completed solution project.


Change map contents

Learn how you can change many elements of your map without writing any code. Return to ArcGIS Pro and alter your map: change the extent, add or remove layers, and change the symbols. Republish your map package and load it on your device.

Change map package

Add a map file picker to allow your user to select the map package. Try starting with QML's FileDialog.