Skip to content

Commit

Permalink
Merge pull request #552 from Esri/destiny/patch-world-scale
Browse files Browse the repository at this point in the history
Update world scale AR
  • Loading branch information
des12437 authored Jan 4, 2024
2 parents e02f704 + d2ba8b1 commit 99e952f
Show file tree
Hide file tree
Showing 126 changed files with 4,022 additions and 581 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 200.2.0;
MARKETING_VERSION = 200.3.0;
PRODUCT_BUNDLE_IDENTIFIER = com.esri.Authentication;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down Expand Up @@ -358,7 +358,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 200.2.0;
MARKETING_VERSION = 200.3.0;
PRODUCT_BUNDLE_IDENTIFIER = com.esri.Authentication;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down
4 changes: 2 additions & 2 deletions Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 200.2.0;
MARKETING_VERSION = 200.3.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.esri.arcgis-swift-sdk-toolkit-examples";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down Expand Up @@ -461,7 +461,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 200.2.0;
MARKETING_VERSION = 200.3.0;
PRODUCT_BUNDLE_IDENTIFIER = "com.esri.arcgis-swift-sdk-toolkit-examples";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
Expand Down
25 changes: 8 additions & 17 deletions Examples/Examples/BookmarksExampleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,14 @@ struct BookmarksExampleView: View {
/// The `Map` with predefined bookmarks.
@State private var map = Map(url: URL(string: "https://www.arcgis.com/home/item.html?id=16f1b8ba37b44dc3884afc8d5f454dd2")!)!

/// The last selected bookmark.
@State var selectedBookmark: Bookmark?

/// Indicates if the `Bookmarks` component is shown or not.
/// - Remark: This allows a developer to control when the `Bookmarks` component is
/// shown/hidden, whether that be in a group of options or a standalone button.
@State var showingBookmarks = false

/// Allows for communication between the `Bookmarks` component and a `MapView` or
/// `SceneView`.
@State var viewpoint: Viewpoint?

var body: some View {
MapViewReader { mapViewProxy in
MapView(map: map, viewpoint: viewpoint)
.onViewpointChanged(kind: .centerAndScale) {
viewpoint = $0
}
.task(id: selectedBookmark) {
if let selectedBookmark, let viewpoint = selectedBookmark.viewpoint {
await mapViewProxy.setViewpoint(viewpoint)
}
}
MapView(map: map)
.toolbar {
ToolbarItem(placement: .primaryAction) {
Button {
Expand All @@ -58,7 +43,13 @@ struct BookmarksExampleView: View {
isPresented: $showingBookmarks,
geoModel: map
)
.onSelectionChanged { selectedBookmark = $0 }
.onSelectionChanged {
if let viewpoint = $0.viewpoint {
Task {
await mapViewProxy.setViewpoint(viewpoint)
}
}
}
}
}
}
Expand Down
13 changes: 12 additions & 1 deletion Examples/Examples/FloatingPanelExampleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import ArcGISToolkit
import ArcGIS

struct FloatingPanelExampleView: View {
/// The height of the map view's attribution bar.
@State private var attributionBarHeight: CGFloat = 0

/// The data model containing the `Map` displayed in the `MapView`.
@StateObject private var dataModel = MapDataModel(
map: Map(basemapStyle: .arcGISImagery)
Expand All @@ -38,7 +41,15 @@ struct FloatingPanelExampleView: View {
map: dataModel.map,
viewpoint: initialViewpoint
)
.floatingPanel(selectedDetent: $selectedDetent, isPresented: isPresented) {
.onAttributionBarHeightChanged {
attributionBarHeight = $0
}
.ignoresSafeArea(.keyboard, edges: .bottom)
.floatingPanel(
attributionBarHeight: attributionBarHeight,
selectedDetent: $selectedDetent,
isPresented: isPresented
) {
switch demoContent {
case .list:
FloatingPanelListDemoContent(selectedDetent: $selectedDetent)
Expand Down
3 changes: 1 addition & 2 deletions Examples/Examples/FlyoverExampleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ struct FlyoverExampleView: View {
var body: some View {
FlyoverSceneView(
initialLocation: Point(x: 4.4777, y: 51.9244, z: 1_000, spatialReference: .wgs84),
initialHeading: 0,
translationFactor: 2_000
translationFactor: 1_000
) { proxy in
SceneView(scene: scene)
.onSingleTapGesture { screen, _ in
Expand Down
25 changes: 10 additions & 15 deletions Examples/Examples/PopupExampleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ struct PopupExampleView: View {
@State private var identifyScreenPoint: CGPoint?

/// The popup to be shown as the result of the layer identify operation.
@State private var popup: Popup?
@State private var popup: Popup? {
didSet { showPopup = popup != nil }
}

/// A Boolean value specifying whether the popup view should be shown or not.
@State private var showPopup = false
Expand All @@ -48,20 +50,13 @@ struct PopupExampleView: View {
identifyScreenPoint = screenPoint
}
.task(id: identifyScreenPoint) {
guard let identifyScreenPoint = identifyScreenPoint,
let identifyResult = await Result(awaiting: {
try await proxy.identifyLayers(
screenPoint: identifyScreenPoint,
tolerance: 10,
returnPopupsOnly: true
)
})
.cancellationToNil()
else {
return
}
self.popup = try? identifyResult.get().first?.popups.first
self.showPopup = self.popup != nil
guard let identifyScreenPoint else { return }
let identifyResult = try? await proxy.identifyLayers(
screenPoint: identifyScreenPoint,
tolerance: 10,
returnPopupsOnly: true
).first
popup = identifyResult?.popups.first
}
.floatingPanel(
selectedDetent: $floatingPanelDetent,
Expand Down
76 changes: 46 additions & 30 deletions Examples/Examples/UtilityNetworkTraceExampleView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ import SwiftUI
/// A demonstration of the utility network trace tool which runs traces on a web map published with
/// a utility network and trace configurations.
struct UtilityNetworkTraceExampleView: View {
@Environment(\.horizontalSizeClass)
private var horizontalSizeClass: UserInterfaceSizeClass?

@Environment(\.verticalSizeClass)
private var verticalSizeClass: UserInterfaceSizeClass?

/// A Boolean value indicating whether the environment is compact.
private var isCompact: Bool {
horizontalSizeClass == .compact && verticalSizeClass == .regular
}

/// The map with the utility networks.
@State private var map = makeMap()

Expand All @@ -37,38 +48,43 @@ struct UtilityNetworkTraceExampleView: View {
@State var viewpoint: Viewpoint?

var body: some View {
MapViewReader { mapViewProxy in
MapView(
map: map,
viewpoint: viewpoint,
graphicsOverlays: [resultGraphicsOverlay]
)
.onSingleTapGesture { screenPoint, mapPoint in
self.screenPoint = screenPoint
self.mapPoint = mapPoint
}
.onViewpointChanged(kind: .centerAndScale) {
viewpoint = $0
}
.task {
let publicSample = try? await ArcGISCredential.publicSample
ArcGISEnvironment.authenticationManager.arcGISCredentialStore.add(publicSample!)
}
.floatingPanel(
backgroundColor: Color(uiColor: .systemGroupedBackground),
selectedDetent: $activeDetent,
horizontalAlignment: .trailing,
isPresented: .constant(true)
) {
UtilityNetworkTrace(
graphicsOverlay: $resultGraphicsOverlay,
GeometryReader { geometryProxy in
MapViewReader { mapViewProxy in
MapView(
map: map,
mapPoint: $mapPoint,
screenPoint: $screenPoint,
mapViewProxy: mapViewProxy,
viewpoint: $viewpoint
viewpoint: viewpoint,
graphicsOverlays: [resultGraphicsOverlay]
)
.floatingPanelDetent($activeDetent)
.onSingleTapGesture { screenPoint, mapPoint in
self.screenPoint = screenPoint
self.mapPoint = mapPoint
}
.onViewpointChanged(kind: .centerAndScale) {
viewpoint = $0
}
.task {
let publicSample = try? await ArcGISCredential.publicSample
ArcGISEnvironment.authenticationManager.arcGISCredentialStore.add(publicSample!)
}
.floatingPanel(
backgroundColor: Color(uiColor: .systemGroupedBackground),
selectedDetent: $activeDetent,
horizontalAlignment: .trailing,
isPresented: .constant(true)
) {
UtilityNetworkTrace(
graphicsOverlay: $resultGraphicsOverlay,
map: map,
mapPoint: $mapPoint,
screenPoint: $screenPoint,
mapViewProxy: mapViewProxy,
viewpoint: $viewpoint
)
.floatingPanelDetent($activeDetent)
// Manually account for a device's bottom safe area when using a Floating Panel.
// See also #518.
.padding(.bottom, isCompact ? geometryProxy.safeAreaInsets.bottom : nil)
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions JobManagerExample/JobManagerExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 200.2.0;
MARKETING_VERSION = 200.3.0;
PRODUCT_BUNDLE_IDENTIFIER = com.esri.JobManagerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -331,7 +331,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 200.2.0;
MARKETING_VERSION = 200.3.0;
PRODUCT_BUNDLE_IDENTIFIER = com.esri.JobManagerExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down
7 changes: 5 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
// Copyright 2021 Esri.

Expand Down Expand Up @@ -29,13 +29,16 @@ let package = Package(
),
],
dependencies: [
.package(url: "https://github.com/Esri/arcgis-maps-sdk-swift", .upToNextMinor(from: "200.2.0"))
.package(url: "https://github.com/Esri/arcgis-maps-sdk-swift", .upToNextMinor(from: "200.3.0"))
],
targets: [
.target(
name: "ArcGISToolkit",
dependencies: [
.product(name: "ArcGIS", package: "arcgis-maps-sdk-swift")
],
resources: [
.copy("PrivacyInfo.xcprivacy")
]
),
.testTarget(
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ To use Toolkit in your project:
* **[Compass](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/compass)** - Shows a compass direction when the map is rotated. Auto-hides when the map points north.
* **[FloatingPanel](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/floatingpanel)** - Allows display of view-related content in a "bottom sheet".
* **[FloorFilter](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/floorfilter)** - Allows filtering of floor plan data in a geo view by a site, a building in the site, or a floor in the building.
* **[FlyoverSceneView](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/flyoversceneview)** - Allows you to explore a scene using your device as a window into the virtual world.
* **[JobManager](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/jobmanager)** - Manages saving and loading jobs so that they can continue to run if the app is backgrounded or even terminated by the system.
* **[OverviewMap](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/overviewmap)** - Displays the visible extent of a geo view in a small "inset" map.
* **[PopupView](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/popupview)** - Displays details, media, and attachments of features and graphics.
* **[Scalebar](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/scalebar)** - Displays current scale reference.
* **[SearchView](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/searchview)** - Displays a search experience for geo views.
* **[TableTopSceneView](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/tabletopsceneview)** - Allows you to anchor scene content to a physical surface, as if it were a 3D-printed model.
* **[UtilityNetworkTrace](https://developers.arcgis.com/swift/toolkit-api-reference/documentation/arcgistoolkit/utilitynetworktrace)** - Runs traces on a web map published with a utility network and trace configurations.

## Requirements
* ArcGIS Maps SDK for Swift
* Xcode 14.1 (or newer)
* Xcode 15.0 (or newer)

The *ArcGIS Maps SDK for Swift Toolkit* has a *Target SDK* version of *15.0*, meaning that it can run on devices with *iOS 15.0* or newer.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2023 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.

import ARKit
import SwiftUI

/// A SwiftUI version of an ARCoachingOverlayView view.
struct ARCoachingOverlay: UIViewRepresentable {
/// The data source for an AR session.
var sessionProvider: ARSessionProviding?
/// The goal for the coaching overlay.
var goal: ARCoachingOverlayView.Goal
/// A Boolean value that indicates if coaching is in progress.
var active: Bool = false

/// Controls whether the coaching is in progress.
/// - Parameter active: A Boolean value indicating if coaching is in progress.
/// - Returns: The `ARCoachingOverlay`.
func active(_ active: Bool) -> Self {
var view = self
view.active = active
return view
}

/// Sets the AR session data source for the coaching overlay.
/// - Parameter sessionProvider: The AR session data source.
/// - Returns: The `ARCoachingOverlay`.
func sessionProvider(_ sessionProvider: ARSessionProviding) -> Self {
var view = self
view.sessionProvider = sessionProvider
return view
}

func makeUIView(context: Context) -> ARCoachingOverlayView {
let view = ARCoachingOverlayView()
view.delegate = context.coordinator
view.activatesAutomatically = false
return view
}

func updateUIView(_ uiView: ARCoachingOverlayView, context: Context) {
uiView.sessionProvider = sessionProvider
uiView.goal = goal
uiView.setActive(active, animated: true)
}

func makeCoordinator() -> Coordinator {
Coordinator()
}

class Coordinator: NSObject, ARCoachingOverlayViewDelegate {}
}
Loading

0 comments on commit 99e952f

Please sign in to comment.