Skip to content

Commit fed206b

Browse files
authored
Merge pull request #89 from Esri/update7
Update7
2 parents 9b8aec6 + 3e19122 commit fed206b

20 files changed

+899
-23
lines changed

Documentation/Bookmarks/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Bookmarks
2+
3+
The Bookmarks component will display a list of bookmarks in a table view and allows the user to select a bookmark and perform some action.
4+
5+
## Bookmarks Behavior:
6+
7+
The `BookmarksTableViewController` can be created using either an `AGSGeoView` or an array of `AGSBookmark`s.
8+
9+
Clients must set the `delegate` property and implement the `bookmarksViewController:didSelect` delegate method in order to be notified when a bookmark is selected.
10+
11+
The `BookmarksTableViewController` observes changes to the `map` or `scene` property on the `AGSGeoView` and also the map or scene's `bookmarks` property and will udpate the list of bookmarks accordingly.
12+
13+
## Usage
14+
15+
```swift
16+
bookmarksVC = BookmarksViewController(geoView: mapView)
17+
bookmarksVC?.delegate = self
18+
19+
...
20+
21+
func bookmarksViewController(_ controller: BookmarksViewController, didSelect bookmark: AGSBookmark) {
22+
if let viewpoint = bookmark.viewpoint {
23+
mapView.setViewpoint(viewpoint, duration: 2.0)
24+
dismiss(animated: true)
25+
}
26+
}
27+
```
28+
29+
To see it in action, try out the [Examples](../../Examples) and refer to [BookmarksExample.swift](../../Examples/ArcGISToolkitExamples/BookmarksExample.swift) in the project.

Examples/ArcGISToolkitExamples.xcodeproj/project.pbxproj

+22-3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
E47B17362304AB7D000C9C8B /* UserDirectionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E47B17342304AB7D000C9C8B /* UserDirectionsView.swift */; };
3232
E47B17372304AB7D000C9C8B /* CalibrationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E47B17352304AB7D000C9C8B /* CalibrationView.swift */; };
3333
E48405751E9BE7E600927208 /* LegendExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = E48405741E9BE7E600927208 /* LegendExample.swift */; };
34+
E48ADDBA23563E17005A53AF /* BookmarksExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = E48ADDB923563E17005A53AF /* BookmarksExample.swift */; };
3435
/* End PBXBuildFile section */
3536

3637
/* Begin PBXContainerItemProxy section */
@@ -55,6 +56,13 @@
5556
remoteGlobalIDString = 8812336F1DF601A700B2EA8E;
5657
remoteInfo = ArcGISToolkit;
5758
};
59+
E4CD706023A8436F000A3B1C /* PBXContainerItemProxy */ = {
60+
isa = PBXContainerItemProxy;
61+
containerPortal = 88B6899F1E96E9AB00B67FAB /* ArcGISToolkit.xcodeproj */;
62+
proxyType = 2;
63+
remoteGlobalIDString = E4685B03237CA3C400F168CF;
64+
remoteInfo = ArcGISToolkitTests;
65+
};
5866
/* End PBXContainerItemProxy section */
5967

6068
/* Begin PBXCopyFilesBuildPhase section */
@@ -97,6 +105,7 @@
97105
E47B17342304AB7D000C9C8B /* UserDirectionsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserDirectionsView.swift; sourceTree = "<group>"; };
98106
E47B17352304AB7D000C9C8B /* CalibrationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalibrationView.swift; sourceTree = "<group>"; };
99107
E48405741E9BE7E600927208 /* LegendExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LegendExample.swift; sourceTree = "<group>"; };
108+
E48ADDB923563E17005A53AF /* BookmarksExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BookmarksExample.swift; sourceTree = "<group>"; };
100109
/* End PBXFileReference section */
101110

102111
/* Begin PBXFrameworksBuildPhase section */
@@ -150,6 +159,7 @@
150159
isa = PBXGroup;
151160
children = (
152161
88B689A41E96E9AC00B67FAB /* ArcGISToolkit.framework */,
162+
E4CD706123A8436F000A3B1C /* ArcGISToolkitTests.xctest */,
153163
);
154164
name = Products;
155165
sourceTree = "<group>";
@@ -166,6 +176,7 @@
166176
883EA74A20741A56006D6F72 /* PopupExample.swift */,
167177
8800656D2228577A00F76945 /* TemplatePickerExample.swift */,
168178
E447A12A2267BB9500578C0B /* ARExample.swift */,
179+
E48ADDB923563E17005A53AF /* BookmarksExample.swift */,
169180
);
170181
name = Examples;
171182
sourceTree = "<group>";
@@ -219,7 +230,7 @@
219230
TargetAttributes = {
220231
8839043A1DF6022A001F3188 = {
221232
CreatedOnToolsVersion = 8.0;
222-
LastSwiftMigration = 1010;
233+
LastSwiftMigration = 1110;
223234
ProvisioningStyle = Automatic;
224235
SystemCapabilities = {
225236
com.apple.BackgroundModes = {
@@ -261,6 +272,13 @@
261272
remoteRef = 88B689A31E96E9AC00B67FAB /* PBXContainerItemProxy */;
262273
sourceTree = BUILT_PRODUCTS_DIR;
263274
};
275+
E4CD706123A8436F000A3B1C /* ArcGISToolkitTests.xctest */ = {
276+
isa = PBXReferenceProxy;
277+
fileType = wrapper.cfbundle;
278+
path = ArcGISToolkitTests.xctest;
279+
remoteRef = E4CD706023A8436F000A3B1C /* PBXContainerItemProxy */;
280+
sourceTree = BUILT_PRODUCTS_DIR;
281+
};
264282
/* End PBXReferenceProxy section */
265283

266284
/* Begin PBXResourcesBuildPhase section */
@@ -325,6 +343,7 @@
325343
88DBC2A11FE83D6000255921 /* JobManagerExample.swift in Sources */,
326344
88B689D11E96EDF400B67FAB /* VCListViewController.swift in Sources */,
327345
E47B16FA22F8DECC000C9C8B /* ARStatusViewController.swift in Sources */,
346+
E48ADDBA23563E17005A53AF /* BookmarksExample.swift in Sources */,
328347
8800656E2228577A00F76945 /* TemplatePickerExample.swift in Sources */,
329348
E47B17362304AB7D000C9C8B /* UserDirectionsView.swift in Sources */,
330349
88B689CE1E96EDF400B67FAB /* ScalebarExample.swift in Sources */,
@@ -499,7 +518,7 @@
499518
PRODUCT_BUNDLE_IDENTIFIER = "com.esri.${PRODUCT_NAME}";
500519
PRODUCT_NAME = "$(TARGET_NAME)";
501520
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
502-
SWIFT_VERSION = 4.2;
521+
SWIFT_VERSION = 5.0;
503522
};
504523
name = Debug;
505524
};
@@ -518,7 +537,7 @@
518537
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
519538
PRODUCT_BUNDLE_IDENTIFIER = "com.esri.${PRODUCT_NAME}";
520539
PRODUCT_NAME = "$(TARGET_NAME)";
521-
SWIFT_VERSION = 4.2;
540+
SWIFT_VERSION = 5.0;
522541
};
523542
name = Release;
524543
};

Examples/ArcGISToolkitExamples/ARExample.swift

+9
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,9 @@ extension ARExample {
554554
let camera = AGSCamera(latitude: center.y, longitude: center.x, altitude: 0, heading: 0, pitch: 90.0, roll: 0)
555555
self?.arView.originCamera = camera
556556
self?.arView.translationFactor = 2000
557+
558+
// Set the clipping distance to limit the data display around the originCamera.
559+
self?.arView.clippingDistance = 750
557560
}
558561
}
559562

@@ -601,6 +604,9 @@ extension ARExample {
601604
let camera = AGSCamera(latitude: center.y, longitude: center.x, altitude: elevation, heading: 0, pitch: 90, roll: 0)
602605
self?.arView.originCamera = camera
603606
self?.arView.translationFactor = 18000
607+
608+
// Reset the clipping distance so we view the full scene.
609+
self?.arView.clippingDistance = 0
604610
}
605611
}
606612
}
@@ -649,6 +655,9 @@ extension ARExample {
649655
let camera = AGSCamera(latitude: center.y, longitude: center.x, altitude: elevation, heading: 0, pitch: 90.0, roll: 0)
650656
self?.arView.originCamera = camera
651657
self?.arView.translationFactor = 1000
658+
659+
// Set the clipping distance to limit the data display around the originCamera.
660+
self?.arView.clippingDistance = 500
652661
}
653662
}
654663
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//
2+
// Copyright 2019 Esri.
3+
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://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 UIKit
16+
import ArcGISToolkit
17+
import ArcGIS
18+
19+
class BookmarksExample: MapViewController, BookmarksViewControllerDelegate {
20+
var bookmarksVC: BookmarksViewController?
21+
var bookmarksButton = UIBarButtonItem()
22+
23+
override func viewDidLoad() {
24+
super.viewDidLoad()
25+
26+
// Add Bookmark button that will display the BookmarksTableViewController.
27+
bookmarksButton = UIBarButtonItem(barButtonSystemItem: .bookmarks, target: self, action: #selector(showBookmarks))
28+
navigationItem.rightBarButtonItem = bookmarksButton
29+
30+
// Create the map from a portal item and assign to the mapView.
31+
let portal = AGSPortal.arcGISOnline(withLoginRequired: false)
32+
let portalItem = AGSPortalItem(portal: portal, itemID: "16f1b8ba37b44dc3884afc8d5f454dd2")
33+
mapView.map = AGSMap(item: portalItem)
34+
35+
// Create the BookmarksTableViewController.
36+
bookmarksVC = BookmarksViewController(geoView: mapView)
37+
38+
// Add a cancel button.
39+
let cancelButton = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(cancel))
40+
bookmarksVC?.navigationItem.rightBarButtonItem = cancelButton
41+
bookmarksVC?.delegate = self
42+
}
43+
44+
@objc
45+
func showBookmarks() {
46+
if let bookmarksVC = bookmarksVC {
47+
// Display the bookmarksVC as a popover controller.
48+
bookmarksVC.modalPresentationStyle = .popover
49+
if let popoverPresentationController = bookmarksVC.popoverPresentationController {
50+
popoverPresentationController.delegate = self
51+
popoverPresentationController.barButtonItem = bookmarksButton
52+
}
53+
present(bookmarksVC, animated: true)
54+
}
55+
}
56+
57+
@objc
58+
func cancel() {
59+
dismiss(animated: true)
60+
}
61+
62+
func bookmarksViewController(_ controller: BookmarksViewController, didSelect bookmark: AGSBookmark) {
63+
if let viewpoint = bookmark.viewpoint {
64+
mapView.setViewpoint(viewpoint, duration: 2.0)
65+
dismiss(animated: true)
66+
}
67+
}
68+
}
69+
70+
extension BookmarksExample: UIPopoverPresentationControllerDelegate {
71+
func presentationController(_ controller: UIPresentationController, viewControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIViewController? {
72+
return UINavigationController(rootViewController: controller.presentedViewController)
73+
}
74+
}

Examples/ArcGISToolkitExamples/ExamplesViewController.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class ExamplesViewController: VCListViewController {
2929
("Time Slider", TimeSliderExample.self, nil),
3030
("Popup Controller", PopupExample.self, nil),
3131
("Template Picker", TemplatePickerExample.self, nil),
32-
("AR", ARExample.self, nil)
32+
("AR", ARExample.self, nil),
33+
("Bookmarks", BookmarksExample.self, nil)
3334
]
3435
}
3536
}

Examples/ArcGISToolkitExamples/JobManagerExample.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class JobManagerExample: TableViewController {
227227
}
228228

229229
// remove task from array now that it's loaded
230-
if let index = self.tasks.index(where: { return $0 === strongTask }) {
230+
if let index = self.tasks.firstIndex(where: { return $0 === strongTask }) {
231231
self.tasks.remove(at: index)
232232
}
233233

@@ -343,6 +343,8 @@ extension AGSJobStatus {
343343
return "Succeeded"
344344
case .started:
345345
return "Started"
346+
@unknown default:
347+
fatalError("Unknown AGSJobStatus")
346348
}
347349
}
348350
}

Examples/ArcGISToolkitExamples/Misc/ARStatusViewController.swift

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ extension AGSLocationDataSourceStatus {
4545
return "Started"
4646
case .failedToStart:
4747
return "Failed to start"
48+
@unknown default:
49+
fatalError("Unknown AGSLocationDataSourceStatus")
4850
}
4951
}
5052
}

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ Toolkit components that will simplify your iOS app development with ArcGIS Runti
1313
* [PopupController](Documentation/PopupController)
1414
* [TemplatePickerViewController](Documentation/TemplatePicker)
1515
* [AR](Documentation/AR)
16+
* [Bookmarks](Documentation/Bookmarks)
1617

1718
## Requirements
18-
* [ArcGIS Runtime SDK for iOS](https://developers.arcgis.com/en/ios/) 100.6.0 (or higher)
19-
* Xcode 10.1 (or higher)
19+
* [ArcGIS Runtime SDK for iOS](https://developers.arcgis.com/en/ios/) 100.7.0 (or higher)
20+
* Xcode 10.2 (or higher)
2021

2122
The *ArcGIS Runtime Toolkit for iOS* has a *Target SDK* version of *11.0*, meaning that it can run on devices with *iOS 11.0* or newer.
2223

@@ -52,8 +53,7 @@ Note that you must also have the __ArcGIS Runtime SDK for iOS__ installed and yo
5253
5. Add `import ArcGISToolkit` in your source code and start using the toolkit components
5354

5455
## SwiftLint
55-
New in the 100.6.0 release is SwiftLint support for both the Toolkit and Examples app. You can install SwiftLint from [here](https://github.com/realm/SwiftLint). It is not necessary to have it installed in order to build, but you will get a warning without it. The specific rules the linter uses can be found in the `swiftlint.yml` files in the `Toolkit` and `Examples` directories.
56-
56+
Both the Toolkit and Examples app support SwiftLint. You can install SwiftLint from [here](https://github.com/realm/SwiftLint). It is not necessary to have it installed in order to build, but you will get a warning without it. The specific rules the linter uses can be found in the `swiftlint.yml` files in the `Toolkit` and `Examples` directories.
5757

5858
## Additional Resources
5959

0 commit comments

Comments
 (0)