Click or drag to resize

MobileMapPackageLoadAsync Method

Load the metadata for the object asynchronously.

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public Task LoadAsync()

Return Value

Type: Task
A task that represents the asynchronous load operation.

Implements

ILoadableLoadAsync
Exceptions
ExceptionCondition
ExpiredExceptionPackage was authored to prevent expired access.
UnpackRequiredExceptionPackage contains data that requires unpack before loading.
Remarks
Will load the metadata if the object is not loaded. Will always call Loaded if this is called.
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.
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.