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.7.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 expiration details for this mobile map package, if provided.
Public propertyItem
Gets the mobile map package's Item describing meta-data 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 an array of Maps from the MobileMapPackage.
Public propertyPath
Gets the path to the mobile map package.
Public propertyVersion
Gets 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
Load or retry 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

A mobile map package is a transport mechanism for mobile maps. It contains metadata about the package (description, thumbnail, etc.), one or more mobile maps, layers, data, and optionally networks and locators. Mobile map packages may contain MobileBasemapLayers. Packages are created in ArcGIS Pro.

Mobile map packages are a major part of the offline workflow. Mobile maps inside a mobile map package can be used and programmatically edited (layers can be added or removed). Note, mobile map packages are read-only; edits to mobile maps or layers are not persisted to disk.

MobileMapPackage implements the Loadable interface; the mobile map package contents can be accessed after the mobile map package has loaded.

The mobile map package has a version property which application developers can use to determine if they can be opened in this version of the ArcGIS Runtime SDK. Pre 1.0 packages which were created in ArcGIS Pro 1.1 are not supported, however, they can be loaded so that their version property and item property (including the title and thumbnail only) can be checked. The version of mobile map package from 1.0 onwards follow the semantic versioning scheme. The ArcGIS Runtime will be backwards compatible back to 1.0 mobile map packages and will open the latest supported major version, but will not be able to open future major versions of packages. Please see the system requirements for details on what mobile map package versions are currently supported.

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(
        "Open mobile map (map package)",
        "Map",
        "This sample demonstrates how to open a map from a mobile map package.",
        "The map package will be downloaded from an ArcGIS Online portal automatically.")]
    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(
        "Open mobile map (map package)",
        "Map",
        "This sample demonstrates how to open a mobile map from a map package.",
        "The map package will be downloaded from an ArcGIS Online portal automatically.")]
    [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 an available 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.