Click or drag to resize

MobileScenePackage Class

A mobile scene package.
Inheritance Hierarchy
SystemObject
  Esri.ArcGISRuntime.MappingMobileScenePackage

Namespace:  Esri.ArcGISRuntime.Mapping
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.7.0.0
Syntax
C#
public sealed class MobileScenePackage : ILoadable

The MobileScenePackage type exposes the following members.

Constructors
  NameDescription
Public methodMobileScenePackage
Initializes a new instance of the MobileScenePackage class.
Top
Properties
  NameDescription
Public propertyExpiration
Gets expiration details for this mobile scene package, if provided.
Public propertyItem
Gets the mobile scene package's Item describing meta-data about the package.
Public propertyLoadError
Gets the Exception associated with the last load error.
Public propertyLoadStatus
Gets the load status.
Public propertyLocatorTask
Gets the LocatorTask from the mobile scene package.
Public propertyPath
Gets the path to the mobile scene package.
Public propertyCode exampleScenes
Gets an array of Scenes from the MobileScenePackage.
Public propertyVersion
Gets the mobile scene package's version.
Top
Methods
  NameDescription
Public methodCancelLoad
Cancel loading metadata for the object.
Public methodClose
Closes a mobile scene package.
Public methodStatic memberIsDirectReadSupportedAsync
Checks if the mobile scene package (.mspk) 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 MobileScenePackage class.
Public methodRetryLoadAsync
Load or retry loading metadata for the object asynchronously.
Public methodStatic memberUnpackAsync(String, String)
Unpacks a scene package file (.mspk) to an output directory.
Public methodStatic memberUnpackAsync(String, String, CancellationToken)
Unpacks a scene package file (.mspk) 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 scene package is a transport mechanism for scenes. It contains metadata about the package (description, thumbnail, etc.), one or more scenes, layers, data, and optionally locators. Packages are created in ArcGIS Pro. Mobile scene packages are a major part of the offline workflow. Scenes inside a mobile scene package can be used and programmatically edited (layers can be added or removed). Note, mobile scene packages are read-only; edits to scenes or layers are not persisted to disk.

The mobile scene 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. The ArcGIS Runtime will be backwards compatible back to 1.0 mobile scene 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 scene package versions are currently supported.

Examples

Android

Example Name: OpenMobileScenePackage

Open and display a scene from a Mobile Scene Package (.mspk).

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 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;
using Debug = System.Diagnostics.Debug;

namespace ArcGISRuntimeXamarin.Samples.OpenMobileScenePackage
{
    [Activity(ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Open mobile scene package",
        "Map",
        "Display a scene from an offline mobile scene package (.mspk).",
        "")]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("7dd2f97bb007466ea939160d0de96a9d")]
    public class OpenMobileScenePackage : Activity
    {
        // Hold references to the UI control.
        private SceneView _mySceneView;

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

            Title = "Open mobile scene package";

            CreateLayout();
            Initialize();
        }

        private async void Initialize()
        {
            // Get the path to the scene package.
            string scenePath = DataManager.GetDataFolder("7dd2f97bb007466ea939160d0de96a9d", "philadelphia.mspk");

            try
            {
                // Open the package.
                MobileScenePackage package = await MobileScenePackage.OpenAsync(scenePath);

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

                // Show the first scene.
                _mySceneView.Scene = package.Scenes.First();
            }
            catch (Exception e)
            {
                new AlertDialog.Builder(this).SetMessage(e.Message).SetTitle("Couldn't open scene").Show();
                Debug.WriteLine(e);
            }
        }

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

            // Add the scene view to the layout.
            _mySceneView = new SceneView(this);
            layout.AddView(_mySceneView);

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

Xamarin Forms Android

Example Name: OpenMobileScenePackage

Open and display a scene from a Mobile Scene Package (.mspk).

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.Diagnostics;
using System.Linq;
using Xamarin.Forms;

namespace ArcGISRuntimeXamarin.Samples.OpenMobileScenePackage
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Open mobile scene package",
        "Map",
        "Display a scene from an offline mobile scene package (.mspk).",
        "")]
    [ArcGISRuntime.Samples.Shared.Attributes.OfflineData("7dd2f97bb007466ea939160d0de96a9d")]
    public partial class OpenMobileScenePackage : ContentPage
    {
        public OpenMobileScenePackage()
        {
            InitializeComponent();
            Initialize();
        }

        private async void Initialize()
        {
            // Get the path to the scene package.
            string scenePath = DataManager.GetDataFolder("7dd2f97bb007466ea939160d0de96a9d", "philadelphia.mspk");

            try
            {
                // Open the package.
                MobileScenePackage package = await MobileScenePackage.OpenAsync(scenePath);

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

                // Show the first scene.
                MySceneView.Scene = package.Scenes.First();
            }
            catch (Exception e)
            {
                await Application.Current.MainPage.DisplayAlert("Couldn't open scene", e.Message, "OK");
                Debug.WriteLine(e);
            }
        }
    }
}
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="ArcGISRuntimeXamarin.Samples.OpenMobileScenePackage.OpenMobileScenePackage">
  <Grid>
    <esriUI:SceneView x:Name="MySceneView"/>
  </Grid>
</ContentPage>
See Also
Additional Examples
Hyperlink to ExampleDescription
OpenMobileScenePackageOpen and display a scene from a Mobile Scene Package (.mspk).