Click or drag to resize

MobileMapPackage Class

A mobile map package.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingMobileMapPackage

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public sealed class MobileMapPackage : ILoadable

The MobileMapPackage type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleMobileMapPackage
Initializes a new instance of the MobileMapPackage class.
Top
Properties
  NameDescription
Public propertyCode exampleExpiration
Gets the expiration details for this mobile map package, if provided.
Public propertyItem
Gets the mobile map package's Item describing metadata about the package.
Public propertyLoadError
Gets the Exception associated with the last load error.
Public propertyCode exampleLoadStatus
Gets the load status.
Public propertyCode exampleLocatorTask
Gets the LocatorTask for the mobile map package.
Public propertyCode exampleMaps
Gets a collection of Maps from the MobileMapPackage.
Public propertyPath
Gets the path to the mobile map package.
Public propertyVersion
Gets the mobile map package's version.
Top
Methods
  NameDescription
Public methodCancelLoad
Cancel loading metadata for the object.
Public methodCode exampleClose
Closes a mobile map package.
Public methodStatic memberIsDirectReadSupportedAsync Obsolete.
Checks if the mobile map package can be read directly without requiring to be unpacked.
Public methodCode exampleLoadAsync
Load the metadata for the object asynchronously.
Public methodStatic memberCode exampleOpenAsync
Opens a new instance of the MobileMapPackage class.
Public methodRetryLoadAsync
Loads or retries loading metadata for the object asynchronously.
Public methodStatic memberUnpackAsync(String, String)
Unpacks a mobile map package file (.mmpk) to an output directory.
Public methodStatic memberUnpackAsync(String, String, CancellationToken)
Unpacks a mobile map package file (.mmpk) to an output directory.
Top
Events
  NameDescription
Public eventLoaded
Event that is raised when the object is done loading.
Public eventLoadStatusChanged
Event that is raised when the LoadStatus property changes.
Top
Remarks

Mobile map packages allow you to work with maps on a mobile device. A mobile map package contains all of the files necessary to work with your maps and is stored on a device as either:

  • A single archive file with a .mmpk extension.
  • A directory containing an unpacked mobile map package.

You can create a mobile map package using either:

A mobile map package can encapsulate one or more maps along with their layers and data. Each package contains an Item with metadata about the package (description, thumbnail, etc.).

Mobile map packages created with ArcGIS Pro can also include transportation networks, locators, and links to online services. You can choose whether to use:

  • A tile package (such as .tpkx or .vptk) or an online basemap as the Basemap.
  • A mobile geodatabase (.geodatabase) or an online feature service as one of the OperationalLayers.
  • Online services (such as traffic or weather) can provide excellent contextual information for your users. If the mobile map package is going to be used in areas of poor connectivity, however, you must ensure that data critical to your workflow is stored locally on the device.

Mobile map packages implement the ILoadable interface; you need to load the MobileMapPackage before you can access its content. Once loaded you can:

  • Determine the version of this package using the Version property. ArcGIS Runtime currently supports mobile map packages up to and including major version 4. If the package is from an unsupported version, it will fail to load.
  • Discover whether the mobile map package has expired using the Expiration property.
  • Access the individual maps and display them in a MapView.
  • Programmatically add, modify, and remove layers in the map. Mobile map packages, however, are read-only and these changes to maps or layers are not persisted.

Examples

WPF

Example Name: OpenMobileMap

Display a map from a mobile map package.

Code example screen shot.

C#
// Copyright 2017 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Mapping;
using System;
using System.Linq;
using System.Windows;

namespace ArcGISRuntime.WPF.Samples.OpenMobileMap
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Open mobile map package",
        category: "Map",
        description: "Display a map from a mobile map package.",
        instructions: "When the sample opens, it will automatically display the map in the mobile map package. Pan and zoom to observe the data from the mobile map package.",
        tags: new[] { "mmpk", "mobile map package", "offline" })]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("e1f3a7254cb845b09450f54937c16061")]
    public partial class OpenMobileMap
    {
        public OpenMobileMap()
        {
            InitializeComponent();
            Initialize();
        }

        private async void Initialize()
        {
            // Get the path to the mobile map package.
            string filepath = GetMmpkPath();

            try
            {
                // Open the package.
                MobileMapPackage package = await MobileMapPackage.OpenAsync(filepath);

                // Load the package.
                await package.LoadAsync();

                // Show the first map.
                MyMapView.Map = package.Maps.First();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), "Error");
            }
        }

        /// <summary>
        /// This abstracts away platform & sample viewer-specific code for accessing local files.
        /// </summary>
        /// <returns>String that is the path to the file on disk.</returns>
        private static string GetMmpkPath()
        {
            return DataManager.GetDataFolder("e1f3a7254cb845b09450f54937c16061", "Yellowstone.mmpk");
        }
    }
}
XAML
<UserControl 
    x:Class="ArcGISRuntime.WPF.Samples.OpenMobileMap.OpenMobileMap"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013" 
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="300">
    <esri:MapView x:Name="MyMapView" />
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
ApplyScheduledUpdatesApply scheduled updates to a downloaded preplanned map area.
ControlAnnotationSublayerVisibilityUse annotation sublayers to gain finer control of annotation layer subtypes.
DownloadPreplannedMapTake a map offline using a preplanned map area.
HonorMobileMapPackageExpirationAccess the expiration information of an expired mobile map package.
MobileMapSearchAndRouteDisplay maps and use locators to enable search and routing offline using a Mobile Map Package.
OpenMobileMapDisplay a map from a mobile map package.