Skip to content

Commit ba7dfd1

Browse files
authored
Merge branch 'v.next' into Caleb/New-DisplayWebSceneFromPortalItem
2 parents 2735c92 + bc0b747 commit ba7dfd1

File tree

5 files changed

+138
-1
lines changed

5 files changed

+138
-1
lines changed

Samples.xcodeproj/project.pbxproj

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@
154154
88F93CC229C4D3480006B28E /* CreateAndEditGeometriesView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = 88F93CC029C3D59C0006B28E /* CreateAndEditGeometriesView.swift */; };
155155
D70082EB2ACF900100E0C3C2 /* IdentifyKMLFeaturesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D70082EA2ACF900100E0C3C2 /* IdentifyKMLFeaturesView.swift */; };
156156
D70082EC2ACF901600E0C3C2 /* IdentifyKMLFeaturesView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D70082EA2ACF900100E0C3C2 /* IdentifyKMLFeaturesView.swift */; };
157+
D7010EBF2B05616900D43F55 /* DisplaySceneFromMobileScenePackageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7010EBC2B05616900D43F55 /* DisplaySceneFromMobileScenePackageView.swift */; };
158+
D7010EC12B05618400D43F55 /* DisplaySceneFromMobileScenePackageView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7010EBC2B05616900D43F55 /* DisplaySceneFromMobileScenePackageView.swift */; };
157159
D701D72C2A37C7F7006FF0C8 /* bradley_low_3ds in Resources */ = {isa = PBXBuildFile; fileRef = D701D72B2A37C7F7006FF0C8 /* bradley_low_3ds */; settings = {ASSET_TAGS = (ShowViewshedFromGeoelementInScene, ); }; };
158160
D704AA5A2AB22C1A00A3BB63 /* GroupLayersTogetherView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D704AA592AB22C1A00A3BB63 /* GroupLayersTogetherView.swift */; };
159161
D704AA5B2AB22D8400A3BB63 /* GroupLayersTogetherView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D704AA592AB22C1A00A3BB63 /* GroupLayersTogetherView.swift */; };
@@ -270,7 +272,7 @@
270272
D7CC34002A3147FF00198EDF /* ShowLineOfSightBetweenPointsView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7CC33FD2A31475C00198EDF /* ShowLineOfSightBetweenPointsView.swift */; };
271273
D7CE9F9B2AE2F575008F7A5F /* streetmap_SD.tpkx in Resources */ = {isa = PBXBuildFile; fileRef = D7CE9F9A2AE2F575008F7A5F /* streetmap_SD.tpkx */; settings = {ASSET_TAGS = (GeocodeOffline, ); }; };
272274
D7CE9FA32AE2F595008F7A5F /* san-diego-eagle-locator in Resources */ = {isa = PBXBuildFile; fileRef = D7CE9FA22AE2F595008F7A5F /* san-diego-eagle-locator */; settings = {ASSET_TAGS = (GeocodeOffline, ); }; };
273-
D7D1F3532ADDBE5D009CE2DA /* philadelphia.mspk in Resources */ = {isa = PBXBuildFile; fileRef = D7D1F3522ADDBE5D009CE2DA /* philadelphia.mspk */; settings = {ASSET_TAGS = (AugmentRealityToShowTabletopScene, ); }; };
275+
D7D1F3532ADDBE5D009CE2DA /* philadelphia.mspk in Resources */ = {isa = PBXBuildFile; fileRef = D7D1F3522ADDBE5D009CE2DA /* philadelphia.mspk */; settings = {ASSET_TAGS = (AugmentRealityToShowTabletopScene, DisplaySceneFromMobileScenePackage, ); }; };
274276
D7DDF84E2AF43AA2004352D9 /* GeocodeOfflineView.Model.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D72C43F22AEB066D00B6157B /* GeocodeOfflineView.Model.swift */; };
275277
D7DDF8532AF47C6C004352D9 /* FindRouteAroundBarriersView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7DDF8502AF47C6C004352D9 /* FindRouteAroundBarriersView.swift */; };
276278
D7DDF8562AF47C86004352D9 /* FindRouteAroundBarriersView.swift in Copy Source Code Files */ = {isa = PBXBuildFile; fileRef = D7DDF8502AF47C6C004352D9 /* FindRouteAroundBarriersView.swift */; };
@@ -380,6 +382,7 @@
380382
files = (
381383
D742E4952B04134C00690098 /* DisplayWebSceneFromPortalItemView.swift in Copy Source Code Files */,
382384
D73FCFFA2B02A3C50006360D /* FindAddressWithReverseGeocodeView.swift in Copy Source Code Files */,
385+
D7010EC12B05618400D43F55 /* DisplaySceneFromMobileScenePackageView.swift in Copy Source Code Files */,
383386
D737237B2AF5AE1A00846884 /* FindRouteInMobileMapPackageView.Models.swift in Copy Source Code Files */,
384387
D737237A2AF5AE1600846884 /* FindRouteInMobileMapPackageView.MobileMapView.swift in Copy Source Code Files */,
385388
D76000B12AF19C4600B3084D /* FindRouteInMobileMapPackageView.swift in Copy Source Code Files */,
@@ -601,6 +604,7 @@
601604
883C121429C9136600062FF9 /* DownloadPreplannedMapAreaView.MapPicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DownloadPreplannedMapAreaView.MapPicker.swift; sourceTree = "<group>"; };
602605
88F93CC029C3D59C0006B28E /* CreateAndEditGeometriesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateAndEditGeometriesView.swift; sourceTree = "<group>"; };
603606
D70082EA2ACF900100E0C3C2 /* IdentifyKMLFeaturesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IdentifyKMLFeaturesView.swift; sourceTree = "<group>"; };
607+
D7010EBC2B05616900D43F55 /* DisplaySceneFromMobileScenePackageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisplaySceneFromMobileScenePackageView.swift; sourceTree = "<group>"; };
604608
D701D72B2A37C7F7006FF0C8 /* bradley_low_3ds */ = {isa = PBXFileReference; lastKnownFileType = folder; path = bradley_low_3ds; sourceTree = "<group>"; };
605609
D704AA592AB22C1A00A3BB63 /* GroupLayersTogetherView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GroupLayersTogetherView.swift; sourceTree = "<group>"; };
606610
D7054AE82ACCCB6C007235BA /* Animate3DGraphicView.SettingsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Animate3DGraphicView.SettingsView.swift; sourceTree = "<group>"; };
@@ -834,6 +838,7 @@
834838
1C56B5DE2A82C02D000381DA /* Display points using clustering feature reduction */,
835839
E004A6D528465C70002A1FE6 /* Display scene */,
836840
D742E48E2B04132B00690098 /* Display web scene from portal item */,
841+
D7010EBA2B05616900D43F55 /* Display scene from mobile scene package */,
837842
E070A0A1286F3B3400F2B606 /* Download preplanned map area */,
838843
E004A6EE284E4B7A002A1FE6 /* Download vector tiles to local cache */,
839844
1C26ED122A859525009B7721 /* Filter features in scene */,
@@ -1289,6 +1294,14 @@
12891294
path = "Identify KML features";
12901295
sourceTree = "<group>";
12911296
};
1297+
D7010EBA2B05616900D43F55 /* Display scene from mobile scene package */ = {
1298+
isa = PBXGroup;
1299+
children = (
1300+
D7010EBC2B05616900D43F55 /* DisplaySceneFromMobileScenePackageView.swift */,
1301+
);
1302+
path = "Display scene from mobile scene package";
1303+
sourceTree = "<group>";
1304+
};
12921305
D701D7242A37C7E4006FF0C8 /* 07d62a792ab6496d9b772a24efea45d0 */ = {
12931306
isa = PBXGroup;
12941307
children = (
@@ -2034,6 +2047,7 @@
20342047
ChangeCameraController,
20352048
DisplayDimensions,
20362049
DisplayMapFromMobileMapPackage,
2050+
DisplaySceneFromMobileScenePackage,
20372051
FindRouteInMobileMapPackage,
20382052
FindRouteInTransportNetwork,
20392053
GeocodeOffline,
@@ -2285,6 +2299,7 @@
22852299
D72C43F32AEB066D00B6157B /* GeocodeOfflineView.Model.swift in Sources */,
22862300
1C9B74C929DB43580038B06F /* ShowRealisticLightAndShadowsView.swift in Sources */,
22872301
D7232EE12AC1E5AA0079ABFF /* PlayKMLTourView.swift in Sources */,
2302+
D7010EBF2B05616900D43F55 /* DisplaySceneFromMobileScenePackageView.swift in Sources */,
22882303
1C56B5E62A82C02D000381DA /* DisplayPointsUsingClusteringFeatureReductionView.swift in Sources */,
22892304
D7337C602ABD142D00A5D865 /* ShowMobileMapPackageExpirationDateView.swift in Sources */,
22902305
00E5401E27F3CCA200CF66D5 /* ContentView.swift in Sources */,
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2023 Esri
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import ArcGIS
16+
import SwiftUI
17+
18+
struct DisplaySceneFromMobileScenePackageView: View {
19+
/// The scene used to create the scene view.
20+
@State private var scene = ArcGIS.Scene()
21+
22+
/// A Boolean value indicating whether the error alert is showing.
23+
@State private var errorAlertIsShowing = false
24+
25+
/// The error shown in the error alert.
26+
@State private var error: Error? {
27+
didSet { errorAlertIsShowing = error != nil }
28+
}
29+
30+
var body: some View {
31+
// Create a scene view with the scene.
32+
SceneView(scene: scene)
33+
.task {
34+
do {
35+
// Create a mobile scene package using a URL to a .mspk file.
36+
let mobileScenePackage = MobileScenePackage(fileURL: .philadelphia)
37+
38+
// Load the package.
39+
try await mobileScenePackage.load()
40+
41+
// Get the first scene from the package.
42+
guard let scene = mobileScenePackage.scenes.first else { return }
43+
44+
// Use the scene to update the scene view.
45+
self.scene = scene
46+
} catch {
47+
self.error = error
48+
}
49+
}
50+
.alert(isPresented: $errorAlertIsShowing, presentingError: error)
51+
}
52+
}
53+
54+
private extension URL {
55+
/// A URL to the local mobile scene package of Philadelphia, PA, USA.
56+
static var philadelphia: URL {
57+
Bundle.main.url(forResource: "philadelphia", withExtension: "mspk")!
58+
}
59+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Display scene from mobile scene package
2+
3+
Opens and displays a scene from a Mobile Scene Package (.mspk).
4+
5+
![Image of display scene from mobile scene package](display-scene-from-mobile-scene-package.png)
6+
7+
## Use case
8+
9+
An .mspk file is an archive containing the data (specifically, basemaps and features), used to display an offline 3D scene.
10+
11+
## How to use the sample
12+
13+
When the sample opens, it will automatically display the Scene in the Mobile Map Package.
14+
15+
## How it works
16+
17+
This sample takes a Mobile Scene Package that was created in ArcGIS Pro, and displays a `Scene` from within the package in a `SceneView`.
18+
19+
1. Create a `MobileScenePackage` using the path to the local .mspk file.
20+
2. Call `MobileScenePackage.load()` and check for any errors.
21+
3. When the `MobileScenePackage` is loaded, obtain the first `Scene` from the `MobileScenePackage.scenes` property.
22+
4. Create a `SceneView` by passing in the scene.
23+
24+
## Relevant API
25+
26+
* MobileScenePackage
27+
* SceneView
28+
29+
## Offline data
30+
31+
This mobile scene package was authored with ArcGIS Pro. It is downloaded from ArcGIS Online automatically.
32+
33+
[This item is available on ArcGIS Online](https://www.arcgis.com/home/item.html?id=7dd2f97bb007466ea939160d0de96a9d).
34+
35+
## Tags
36+
37+
offline, scene
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"category": "Scenes",
3+
"description": "Opens and displays a scene from a Mobile Scene Package (.mspk).",
4+
"ignore": false,
5+
"images": [
6+
"display-scene-from-mobile-scene-package.png"
7+
],
8+
"keywords": [
9+
"offline",
10+
"scene",
11+
"MobileScenePackage",
12+
"SceneView"
13+
],
14+
"offline_data": [
15+
"7dd2f97bb007466ea939160d0de96a9d"
16+
],
17+
"redirect_from": [],
18+
"relevant_apis": [
19+
"MobileScenePackage",
20+
"SceneView"
21+
],
22+
"snippets": [
23+
"DisplaySceneFromMobileScenePackageView.swift"
24+
],
25+
"title": "Display scene from mobile scene package"
26+
}
221 KB
Loading

0 commit comments

Comments
 (0)