@@ -16,36 +16,36 @@ class MainViewController: UIViewController {
16
16
static let defaultZoomLevel = 14.0
17
17
}
18
18
19
- @IBOutlet weak var mapView: MTMapView! {
19
+ @IBOutlet private weak var mapView: MTMapView! {
20
20
didSet {
21
21
mapView.delegate = self
22
22
}
23
23
}
24
24
25
- @IBOutlet weak var mapControlView: MapControlView! {
25
+ @IBOutlet private weak var mapControlView: MapControlView! {
26
26
didSet {
27
27
mapControlView.delegate = self
28
28
}
29
29
}
30
30
31
- @IBOutlet weak var mapZoomControlView: MapZoomControlView! {
31
+ @IBOutlet private weak var mapZoomControlView: MapZoomControlView! {
32
32
didSet {
33
33
mapZoomControlView.delegate = self
34
34
}
35
35
}
36
36
37
- @IBOutlet weak var mapProjectionControlView: MapProjectionControlView! {
37
+ @IBOutlet private weak var mapProjectionControlView: MapProjectionControlView! {
38
38
didSet {
39
39
mapProjectionControlView.delegate = self
40
40
}
41
41
}
42
42
43
- @IBOutlet weak var jumpContainerView: UIView!
44
- @IBOutlet weak var benchmarkButton: UIButton!
45
- @IBOutlet weak var loadingActivityIndicator: UIActivityIndicatorView!
46
- @IBOutlet weak var layerViewLeadingConstraint: NSLayoutConstraint!
43
+ @IBOutlet private weak var jumpContainerView: UIView!
44
+ @IBOutlet private weak var benchmarkButton: UIButton!
45
+ @IBOutlet private weak var loadingActivityIndicator: UIActivityIndicatorView!
46
+ @IBOutlet private weak var layerViewLeadingConstraint: NSLayoutConstraint!
47
47
48
- @IBOutlet weak var layerView: LayerView! {
48
+ @IBOutlet private weak var layerView: LayerView! {
49
49
didSet {
50
50
layerView.delegate = self
51
51
}
@@ -81,7 +81,7 @@ class MainViewController: UIViewController {
81
81
82
82
override func viewWillDisappear(_ animated: Bool) {
83
83
super.viewWillDisappear(animated)
84
-
84
+
85
85
AppDelegate.AppUtility.lockOrientation(.all)
86
86
}
87
87
@@ -132,7 +132,7 @@ class MainViewController: UIViewController {
132
132
133
133
private func observeJumpCoordinates() {
134
134
dataModel.$jumpCoordinates
135
- .compactMap{ $0 }
135
+ .compactMap { $0 }
136
136
.sink { [weak self] coordinates in
137
137
self?.jumpTo(coordinates)
138
138
}
@@ -146,17 +146,21 @@ class MainViewController: UIViewController {
146
146
}
147
147
148
148
private func addSources() {
149
- if let contoursURL = URL(string: "https://api.maptiler.com/tiles/contours-v2/{z}/{x}/{y}.pbf?key=F88dOilbnFebWsh4o9oP") {
150
- Task {
151
- let contoursSource = MTVectorTileSource(identifier: "contourssource", tiles: [contoursURL])
152
- try await mapView.style?.addSource(contoursSource)
153
- }
154
- }
155
-
156
- if let openMapURL = URL(string: "https://api.maptiler.com/tiles/v3-openmaptiles/{z}/{x}/{y}.pbf?key=F88dOilbnFebWsh4o9oP") {
157
- Task {
158
- let aerowaySource = MTVectorTileSource(identifier: "openmapsource", tiles: [openMapURL])
159
- try await mapView.style?.addSource(aerowaySource)
149
+ Task {
150
+ if let mapTilerAPIKey = await MTConfig.shared.getAPIKey() {
151
+ if let openMapURL = URL(
152
+ string: "https://api.maptiler.com/tiles/v3-openmaptiles/tiles.json?key=\(mapTilerAPIKey)"
153
+ ) {
154
+ let aerowaySource = MTVectorTileSource(identifier: "openmapsource", url: openMapURL)
155
+ try await mapView.style?.addSource(aerowaySource)
156
+ }
157
+
158
+ if let contoursURL = URL(
159
+ string: "https://api.maptiler.com/tiles/contours-v2/tiles.json?key=\(mapTilerAPIKey)"
160
+ ) {
161
+ let contoursSource = MTVectorTileSource(identifier: "contourssource", url: contoursURL)
162
+ try await mapView.style?.addSource(contoursSource)
163
+ }
160
164
}
161
165
}
162
166
}
@@ -222,7 +226,7 @@ extension MainViewController: MapProjectionControlViewDelegate {
222
226
globeEnabled = !globeEnabled
223
227
}
224
228
}
225
-
229
+
226
230
func mapProjectionControlViewDidTapEnableTerrain(_ mapProjectionControlView: MapProjectionControlView) {
227
231
Task {
228
232
if terrainEnabled {
@@ -249,12 +253,12 @@ extension MainViewController: MTMapViewDelegate {
249
253
250
254
loadingActivityIndicator.stopAnimating()
251
255
252
- // *** Uncomment for benchmark or use long press on jump view ***
256
+ // *** Uncomment for benchmark or use long press on jump view ***
253
257
// Task {
254
258
// benchmarkButton.isHidden = false
255
259
// await MTConfig.shared.setLogLevel(.none)
256
260
// }
257
- // *** ***
261
+ // *** ***
258
262
}
259
263
260
264
func mapView(_ mapView: MTMapView, didTriggerEvent event: MTEvent, with data: MTData?) {
0 commit comments