Skip to content

Commit a5a2a1f

Browse files
committed
Fix few issues after upgrading sdk
1 parent 197e084 commit a5a2a1f

File tree

4 files changed

+64
-99
lines changed

4 files changed

+64
-99
lines changed

arcgis_map_sdk_ios/ios/arcgis_map_sdk_ios/Sources/arcgis_map_sdk_ios/ArcgisMapView.swift

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
5959
scale: ArcgisMapView.convertZoomLevelToMapScale(Int(mapOptions.zoom))
6060
)
6161

62-
mapContentView = MapContentView(mapViewModel: MapViewModel(viewpoint: viewpoint))
62+
mapContentView = MapContentView(viewModel: MapViewModel(viewpoint: viewpoint))
6363

6464
// Embed the SwiftUI MapView into a UIHostingController
6565
hostingController = UIHostingController(rootView: mapContentView)
@@ -69,28 +69,28 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
6969
super.init()
7070

7171
if let isAttributionTextVisible = mapOptions.isAttributionTextVisible {
72-
mapContentView.mapViewModel.attributionBarHidden = !isAttributionTextVisible
72+
mapContentView.viewModel.attributionBarHidden = !isAttributionTextVisible
7373
}
7474

7575
if mapOptions.basemap != nil {
76-
mapContentView.mapViewModel.map.basemap = Basemap(style: parseBaseMapStyle(mapOptions.basemap!))
76+
mapContentView.viewModel.map.basemap = Basemap(style: parseBaseMapStyle(mapOptions.basemap!))
7777
} else {
7878
let layers = mapOptions.vectorTilesUrls!.map { url in
7979
ArcGISVectorTiledLayer(url: URL(string: url)!)
8080
}
81-
mapContentView.mapViewModel.map.basemap = Basemap(baseLayers: layers)
81+
mapContentView.viewModel.map.basemap = Basemap(baseLayers: layers)
8282
}
8383

84-
mapContentView.mapViewModel.map.minScale = ArcgisMapView.convertZoomLevelToMapScale(mapOptions.minZoom)
85-
mapContentView.mapViewModel.map.maxScale = ArcgisMapView.convertZoomLevelToMapScale(mapOptions.maxZoom)
84+
mapContentView.viewModel.map.minScale = ArcgisMapView.convertZoomLevelToMapScale(mapOptions.minZoom)
85+
mapContentView.viewModel.map.maxScale = ArcgisMapView.convertZoomLevelToMapScale(mapOptions.maxZoom)
8686

87-
mapContentView.mapViewModel.onScaleChanged = { [weak self] scale in
87+
mapContentView.viewModel.onScaleChanged = { [weak self] scale in
8888
guard let self = self else { return }
8989
guard !scale.isNaN else { return }
9090
let newZoom = self.convertScaleToZoomLevel(scale)
9191
self.zoomStreamHandler.addZoom(zoom: newZoom)
9292
}
93-
mapContentView.mapViewModel.onVisibleAreaChanged = { [weak self] polygon in
93+
mapContentView.viewModel.onVisibleAreaChanged = { [weak self] polygon in
9494
guard let self = self else { return }
9595
let center = polygon.extent.center
9696
if let wgs84Center = GeometryEngine.project(center, into: .wgs84) as? Point {
@@ -101,7 +101,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
101101
setMapInteractive(mapOptions.isInteractive)
102102
setupMethodChannel()
103103

104-
mapContentView.mapViewModel.onLoadStatusChanged = { [weak self] status in
104+
mapContentView.viewModel.onLoadStatusChanged = { [weak self] status in
105105
guard let self = self else { return }
106106
DispatchQueue.main.async {
107107
self.notifyStatus(status)
@@ -144,7 +144,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
144144
}
145145

146146
private func onZoomIn(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
147-
let currentScale = mapContentView.mapViewModel.viewpoint.targetScale
147+
let currentScale = mapContentView.viewModel.viewpoint.targetScale
148148

149149
guard let args = call.arguments as? [String: Any] else {
150150
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
@@ -158,7 +158,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
158158

159159
let currentZoomLevel = convertScaleToZoomLevel(currentScale)
160160
let totalZoomLevel = currentZoomLevel + lodFactor
161-
if let maxScale = mapContentView.mapViewModel.map.maxScale {
161+
if let maxScale = mapContentView.viewModel.map.maxScale {
162162
if totalZoomLevel > convertScaleToZoomLevel(maxScale) {
163163
result(true)
164164
return
@@ -167,14 +167,14 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
167167
let newScale = ArcgisMapView.convertZoomLevelToMapScale(totalZoomLevel)
168168
Task {
169169
do {
170-
await mapContentView.mapViewModel.mapViewProxy?.setViewpointScale(newScale)
170+
await mapContentView.viewModel.mapViewProxy?.setViewpointScale(newScale)
171171
result(true)
172172
}
173173
}
174174
}
175175

176176
private func onZoomOut(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
177-
let currentScale = mapContentView.mapViewModel.viewpoint.targetScale
177+
let currentScale = mapContentView.viewModel.viewpoint.targetScale
178178

179179
guard let args = call.arguments as? [String: Any] else {
180180
result(FlutterError(code: "missing_data", message: "Invalid arguments", details: nil))
@@ -188,7 +188,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
188188

189189
let currentZoomLevel = convertScaleToZoomLevel(currentScale)
190190
let totalZoomLevel = currentZoomLevel - lodFactor
191-
if let minScale = mapContentView.mapViewModel.map.minScale {
191+
if let minScale = mapContentView.viewModel.map.minScale {
192192
if totalZoomLevel < convertScaleToZoomLevel(minScale) {
193193
result(true)
194194
return
@@ -197,7 +197,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
197197
let newScale = ArcgisMapView.convertZoomLevelToMapScale(totalZoomLevel)
198198
Task {
199199
do {
200-
let success = await mapContentView.mapViewModel.mapViewProxy?.setViewpointScale(newScale)
200+
let success = await mapContentView.viewModel.mapViewProxy?.setViewpointScale(newScale)
201201
result(success)
202202
}
203203
}
@@ -210,7 +210,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
210210
}
211211
Task {
212212
do {
213-
let success = await mapContentView.mapViewModel.mapViewProxy?.setViewpointRotation(angleDouble)
213+
let success = await mapContentView.viewModel.mapViewProxy?.setViewpointRotation(angleDouble)
214214
result(success)
215215
}
216216
}
@@ -225,7 +225,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
225225
do {
226226
let padding: ViewPadding = try JsonUtil.objectOfJson(args)
227227

228-
mapContentView.mapViewModel.contentInsets = EdgeInsets(
228+
mapContentView.viewModel.contentInsets = EdgeInsets(
229229
top: padding.top,
230230
leading: padding.left,
231231
bottom: padding.bottom,
@@ -255,9 +255,9 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
255255
if let zoomLevel = zoomLevel {
256256
scale = ArcgisMapView.convertZoomLevelToMapScale(zoomLevel)
257257
} else {
258-
scale = mapContentView.mapViewModel.viewpoint.targetScale
258+
scale = mapContentView.viewModel.viewpoint.targetScale
259259
}
260-
let success = await mapContentView.mapViewModel.mapViewProxy?.setViewpoint(
260+
let success = await mapContentView.viewModel.mapViewProxy?.setViewpoint(
261261
Viewpoint(center: point.toAGSPoint(), scale: scale),
262262
duration: (animationOptions?.duration ?? 0) / 1000,
263263
)
@@ -279,10 +279,10 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
279279
let polyline = Polyline(points: payload.points.map { latLng in Point(x: latLng.longitude, y:latLng.latitude, spatialReference: .wgs84) })
280280

281281
if(payload.padding != nil) {
282-
let success = try await mapContentView.mapViewModel.mapViewProxy!.setViewpointGeometry(polyline.extent, padding: payload.padding!)
282+
let success = try await mapContentView.viewModel.mapViewProxy!.setViewpointGeometry(polyline.extent, padding: payload.padding!)
283283
result(success)
284284
} else {
285-
let success = try await mapContentView.mapViewModel.mapViewProxy!.setViewpointGeometry(polyline.extent)
285+
let success = try await mapContentView.viewModel.mapViewProxy!.setViewpointGeometry(polyline.extent)
286286
result(success)
287287
}
288288
} catch {
@@ -302,7 +302,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
302302
}
303303

304304

305-
let existingIds = mapContentView.mapViewModel.defaultGraphicsOverlay.graphics.compactMap { object in
305+
let existingIds = mapContentView.viewModel.defaultGraphicsOverlay.graphics.compactMap { object in
306306
let graphic = object as! Graphic
307307
return graphic.attributes["id"] as? String
308308
}
@@ -325,7 +325,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
325325
// them in this for loop instead.
326326
// ArcGis is the best <3.
327327
newGraphics.forEach {
328-
mapContentView.mapViewModel.defaultGraphicsOverlay.addGraphic($0)
328+
mapContentView.viewModel.defaultGraphicsOverlay.addGraphic($0)
329329
}
330330
result(true)
331331
}
@@ -336,15 +336,15 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
336336
return
337337
}
338338

339-
let selectedGraphics = mapContentView.mapViewModel.defaultGraphicsOverlay.graphics.filter { element in
339+
let selectedGraphics = mapContentView.viewModel.defaultGraphicsOverlay.graphics.filter { element in
340340
if let graphic = element as? Graphic,
341341
let id = graphic.attributes["id"] as? String {
342342
return id == graphicId
343343
}
344344
return false
345345
}
346346

347-
mapContentView.mapViewModel.defaultGraphicsOverlay.removeGraphics(selectedGraphics)
347+
mapContentView.viewModel.defaultGraphicsOverlay.removeGraphics(selectedGraphics)
348348
result(true)
349349
}
350350

@@ -354,14 +354,14 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
354354
return
355355
}
356356

357-
mapContentView.mapViewModel.map.basemap = Basemap(style: parseBaseMapStyle(baseMapString))
357+
mapContentView.viewModel.map.basemap = Basemap(style: parseBaseMapStyle(baseMapString))
358358
result(true)
359359
}
360360

361361
private func onRetryLoad(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
362362
Task {
363363
do {
364-
try await mapContentView.mapViewModel.map.retryLoad()
364+
try await mapContentView.viewModel.map.retryLoad()
365365
result(true)
366366
}
367367
}
@@ -387,7 +387,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
387387
}
388388

389389
private func setMapInteractive(_ enabled: Bool) {
390-
mapContentView.mapViewModel.interactionModes = enabled ? .all : []
390+
mapContentView.viewModel.interactionModes = enabled ? .all : []
391391
}
392392

393393
private func parseBaseMapStyle(_ string: String) -> Basemap.Style {
@@ -421,7 +421,7 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
421421
private func onStartLocationDisplayDataSource(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
422422
Task {
423423
do {
424-
try await mapContentView.mapViewModel.locationDisplay.dataSource.start();
424+
try await mapContentView.viewModel.locationDisplay.dataSource.start();
425425
result(true)
426426
}
427427
catch{
@@ -438,22 +438,22 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
438438
private func onStopLocationDisplayDataSource(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
439439
Task {
440440
do {
441-
await mapContentView.mapViewModel.locationDisplay.dataSource.stop()
441+
await mapContentView.viewModel.locationDisplay.dataSource.stop()
442442
result(true)
443443
}
444444
}
445445
}
446446

447447
private func onSetLocationDisplayDefaultSymbol(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
448-
operationWithSymbol(call, result) { mapContentView.mapViewModel.locationDisplay.defaultSymbol = $0 }
448+
operationWithSymbol(call, result) { mapContentView.viewModel.locationDisplay.defaultSymbol = $0 }
449449
}
450450

451451
private func onSetLocationDisplayAccuracySymbol(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
452-
operationWithSymbol(call, result) { mapContentView.mapViewModel.locationDisplay.accuracySymbol = $0 }
452+
operationWithSymbol(call, result) { mapContentView.viewModel.locationDisplay.accuracySymbol = $0 }
453453
}
454454

455455
private func onSetLocationDisplayPingAnimationSymbol(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
456-
operationWithSymbol(call, result) { mapContentView.mapViewModel.locationDisplay.pingAnimationSymbol = $0 }
456+
operationWithSymbol(call, result) { mapContentView.viewModel.locationDisplay.pingAnimationSymbol = $0 }
457457
}
458458

459459
private func onSetLocationDisplayUseCourseSymbolOnMove(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
@@ -462,12 +462,12 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
462462
return
463463
}
464464

465-
mapContentView.mapViewModel.locationDisplay.usesCourseSymbolOnMovement = active
465+
mapContentView.viewModel.locationDisplay.usesCourseSymbolOnMovement = active
466466
result(true)
467467
}
468468

469469
private func onUpdateLocationDisplaySourcePositionManually(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
470-
let dataSource = mapContentView.mapViewModel.locationDisplay.dataSource
470+
let dataSource = mapContentView.viewModel.locationDisplay.dataSource
471471
guard let source = dataSource as? CustomLocationDataSource<CustomLocationProvider> else {
472472
result(FlutterError(code: "invalid_state", message: "Expected ManualLocationDataSource but got \(dataSource)", details: nil))
473473
return
@@ -493,14 +493,14 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
493493
return
494494
}
495495

496-
mapContentView.mapViewModel.locationDisplay.autoPanMode = autoPanMode
496+
mapContentView.viewModel.locationDisplay.autoPanMode = autoPanMode
497497
result(true)
498498
}
499499

500500
private func onGetAutoPanMode(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
501501
// autoPanMode.rawValue is any of [0; 3]:
502502
// https://developers.arcgis.com/ios/api-reference/_a_g_s_location_display_8h.html
503-
guard let stringName = mapContentView.mapViewModel.locationDisplay.autoPanMode.toName() else {
503+
guard let stringName = mapContentView.viewModel.locationDisplay.autoPanMode.toName() else {
504504
result(FlutterError(code: "invalid_data", message: "AutoPanMode has invalid state", details: nil))
505505
return
506506
}
@@ -513,16 +513,16 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
513513
return
514514
}
515515

516-
mapContentView.mapViewModel.locationDisplay.wanderExtentFactor = Float(factor)
516+
mapContentView.viewModel.locationDisplay.wanderExtentFactor = Float(factor)
517517
result(true)
518518
}
519519

520520
private func onGetWanderExtentFactor(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
521-
return result(mapContentView.mapViewModel.locationDisplay.wanderExtentFactor)
521+
return result(mapContentView.viewModel.locationDisplay.wanderExtentFactor)
522522
}
523523

524524
private func onSetLocationDisplayDataSourceType(_ call: FlutterMethodCall, _ result: @escaping FlutterResult) {
525-
if(mapContentView.mapViewModel.locationDisplay.dataSource.status == .started) {
525+
if(mapContentView.viewModel.locationDisplay.dataSource.status == .started) {
526526
result(FlutterError(code: "invalid_state", message: "Current data source is running. Make sure to stop it before setting a new data source", details: nil))
527527
return
528528
}
@@ -534,12 +534,12 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
534534

535535
switch(type) {
536536
case "manual" :
537-
mapContentView.mapViewModel.locationDisplay.dataSource = CustomLocationDataSource{
537+
mapContentView.viewModel.locationDisplay.dataSource = CustomLocationDataSource{
538538
return CustomLocationProvider()
539539
}
540540
result(true)
541541
case "system" :
542-
mapContentView.mapViewModel.locationDisplay.dataSource = SystemLocationDataSource()
542+
mapContentView.viewModel.locationDisplay.dataSource = SystemLocationDataSource()
543543
result(true)
544544
default:
545545
result(FlutterError(code: "invalid_data", message: "Unknown data source type \(String(describing: type))", details: nil))
@@ -552,14 +552,14 @@ class ArcgisMapView: NSObject, FlutterPlatformView {
552552
return
553553
}
554554

555-
mapContentView.mapViewModel.attributionBarHidden = !isVisible
555+
mapContentView.viewModel.attributionBarHidden = !isVisible
556556
result(true)
557557
}
558558

559559
private func onExportImage(_ result: @escaping FlutterResult) {
560560
Task {
561561
do {
562-
let image = try await mapContentView.mapViewModel.mapViewProxy!.exportImage()
562+
let image = try await mapContentView.viewModel.mapViewProxy!.exportImage()
563563
if let imageData = image.pngData() {
564564
result(FlutterStandardTypedData(bytes: imageData))
565565
} else {

arcgis_map_sdk_ios/ios/arcgis_map_sdk_ios/Sources/arcgis_map_sdk_ios/ManualLocationDataSource.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@
88
import Foundation
99
import ArcGIS
1010

11-
//class ManualLocationDataSource: LocationDataSource {
12-
// public func setNewLocation(_ position: UserPosition) {
13-
// let loc = Location(
14-
// position: position.latLng.toAGSPoint(),
15-
// horizontalAccuracy: position.accuracy ?? 0,
16-
// velocity: position.velocity ?? 0,
17-
// course: position.heading ?? 0,
18-
// lastKnown: false
19-
// )
20-
// didUpdate(loc)
21-
// }
22-
//}
23-
2411
final class CustomLocationProvider: LocationProvider {
2512
private var locationContinuation: AsyncThrowingStream<Location, Error>.Continuation?
2613

0 commit comments

Comments
 (0)