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.0
Syntax
C#
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
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

Android

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 Android.App;
using Android.OS;
using Android.Widget;
using ArcGISRuntime.Samples.Managers;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.UI.Controls;
using System;
using System.Linq;

namespace ArcGISRuntime.Samples.OpenMobileMap
{
    [Activity(ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("e1f3a7254cb845b09450f54937c16061")]
    [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" })]
    public class OpenMobileMap : Activity
    {
        private MapView _myMapView;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            Title = "Open mobile map (map package)";

            CreateLayout();
            Initialize();
        }

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

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

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

                // Display the first map in the package.
                _myMapView.Map = myMapPackage.Maps.First();
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show();
            }
        }

        /// <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 string GetMmpkPath()
        {
            return DataManager.GetDataFolder("e1f3a7254cb845b09450f54937c16061", "Yellowstone.mmpk");
        }

        private void CreateLayout()
        {
            // Create a new vertical layout for the app.
            LinearLayout layout = new LinearLayout(this) { Orientation = Orientation.Vertical };

            // Add a map view to the layout.
            _myMapView = new MapView(this);
            layout.AddView(_myMapView);

            // Show the layout in the app.
            SetContentView(layout);
        }
    }
}
Examples

Xamarin Forms Android

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 Xamarin.Forms;

namespace ArcGISRuntime.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 : ContentPage
    {
        public OpenMobileMap()
        {
            InitializeComponent();
            Initialize();
        }

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

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

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

                // Display the first map in the package.
                MyMapView.Map = myMapPackage.Maps.First();
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK");
            }
        }

        /// <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 string GetMmpkPath()
        {
            return DataManager.GetDataFolder("e1f3a7254cb845b09450f54937c16061", "Yellowstone.mmpk");
        }
    }
}
XAML
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms"
             xmlns:mapping="clr-namespace:Esri.ArcGISRuntime.Mapping;assembly=Esri.ArcGISRuntime" 
             x:Class="ArcGISRuntime.Samples.OpenMobileMap.OpenMobileMap">
    <esriUI:MapView x:Name="MyMapView"/>
</ContentPage>
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.