Click or drag to resize

MobileMapPackage Constructor

Initializes a new instance of the MobileMapPackage class.

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.11.0
Syntax
public MobileMapPackage(
	string path
)

Parameters

path
Type: SystemString
A path to a mobile map package.
Remarks
The path can refer to a file with an .mmpk extension or a directory containing an unpacked mobile map package.
Examples

WPF

Example Name: ControlAnnotationSublayerVisibility

Use annotation sublayers to gain finer control of annotation layer subtypes.

Code example screen shot.

C#
// Copyright 2019 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.Media;

namespace ArcGISRuntime.WPF.Samples.ControlAnnotationSublayerVisibility
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        name: "Control annotation sublayer visibility",
        category: "Layers",
        description: "Use annotation sublayers to gain finer control of annotation layer subtypes.",
        instructions: "Start the sample and take note of the visibility of the annotation. Zoom in and out to see the annotation turn on and off based on scale ranges set on the data.",
        tags: new[] { "annotation", "scale", "text", "utilities", "visualization", "Featured" })]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("b87307dcfb26411eb2e92e1627cb615b")]
    public partial class ControlAnnotationSublayerVisibility
    {
        // Mobile map package that contains annotation layers.
        private MobileMapPackage _mobileMapPackage;

        // Sub layers of the annotation layer.
        private AnnotationSublayer _openSublayer;
        private AnnotationSublayer _closedSublayer;

        public ControlAnnotationSublayerVisibility()
        {
            InitializeComponent();
            Initialize();
        }

        private async void Initialize()
        {
            try
            {
                // Load the mobile map package.
                _mobileMapPackage = new MobileMapPackage(DataManager.GetDataFolder("b87307dcfb26411eb2e92e1627cb615b", "GasDeviceAnno.mmpk"));
                await _mobileMapPackage.LoadAsync();

                // Set the mapview to display the map from the package.
                MyMapView.Map = _mobileMapPackage.Maps.First();

                // Get the annotation layer from the MapView operational layers.
                AnnotationLayer annotationLayer = (AnnotationLayer)MyMapView.Map.OperationalLayers.Where(layer => layer is AnnotationLayer).First();

                // Load the annotation layer.
                await annotationLayer.LoadAsync();

                // Get the annotation sub layers.
                _closedSublayer = (AnnotationSublayer)annotationLayer.SublayerContents[0];
                _openSublayer = (AnnotationSublayer)annotationLayer.SublayerContents[1];

                // Set the label content.
                OpenLabel.Content = $"{_openSublayer.Name} (1:{_openSublayer.MaxScale} - 1:{_openSublayer.MinScale})";
                ClosedLabel.Content = _closedSublayer.Name;

                // Enable the check boxes.
                OpenCheckBox.IsEnabled = true;
                ClosedCheckBox.IsEnabled = true;

                // Add event handler for changing the text to indicate whether the "open" sublayer is visible at the current scale.
                MyMapView.ViewpointChanged += (s, e) =>
                {
                    // Check if the sublayer is visible at the current map scale.
                    if (_openSublayer.IsVisibleAtScale(MyMapView.MapScale))
                    {
                        OpenLabel.Foreground = new SolidColorBrush(Colors.Black);
                    }
                    else
                    {
                        OpenLabel.Foreground = new SolidColorBrush(Colors.Gray);
                    }

                    // Set the current map scale text.
                    ScaleLabel.Content = "Current map scale: 1:" + (int)MyMapView.MapScale;
                };
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }

        private void OpenCheckBoxChanged(object sender, System.Windows.RoutedEventArgs e)
        {
            // Set the visibility of the sub layer.
            if (_openSublayer != null) _openSublayer.IsVisible = OpenCheckBox.IsChecked == true;
        }

        private void ClosedCheckBoxChanged(object sender, System.Windows.RoutedEventArgs e)
        {
            // Set the visibility of the sub layer.
            if (_closedSublayer != null) _closedSublayer.IsVisible = ClosedCheckBox.IsChecked == true;
        }
    }
}
XAML
<UserControl
    x:Class="ArcGISRuntime.WPF.Samples.ControlAnnotationSublayerVisibility.ControlAnnotationSublayerVisibility"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <Grid Grid.Row="0" HorizontalAlignment="Left">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto" />
                        <ColumnDefinition Width="auto" />
                    </Grid.ColumnDefinitions>
                    <CheckBox
                        x:Name="OpenCheckBox"
                        Grid.Column="0"
                        VerticalAlignment="Center"
                        VerticalContentAlignment="Center"
                        Checked="OpenCheckBoxChanged"
                        IsChecked="True"
                        IsEnabled="False"
                        Unchecked="OpenCheckBoxChanged">
                        <Label
                            x:Name="OpenLabel"
                            Grid.Column="1"
                            Content="Open" />
                    </CheckBox>
                </Grid>
                <Grid Grid.Row="1" HorizontalAlignment="Left">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto" />
                        <ColumnDefinition Width="auto" />
                    </Grid.ColumnDefinitions>
                    <CheckBox
                        x:Name="ClosedCheckBox"
                        Grid.Column="0"
                        VerticalAlignment="Center"
                        VerticalContentAlignment="Center"
                        Checked="ClosedCheckBoxChanged"
                        IsChecked="True"
                        IsEnabled="False"
                        Unchecked="ClosedCheckBoxChanged">
                        <Label
                            x:Name="ClosedLabel"
                            Grid.Column="1"
                            Content="Closed" />
                    </CheckBox>
                </Grid>
                <Label
                    x:Name="ScaleLabel"
                    Grid.Row="2"
                    HorizontalAlignment="Stretch"
                    HorizontalContentAlignment="Center"
                    Content="Current map scale: 1:" />
            </Grid>
        </Border>
    </Grid>
</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.