react-native-google-maps-plus 1.10.0 → 1.10.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,13 +42,10 @@ GMSIndoorDisplayDelegate {
42
42
  super.init(frame: frame)
43
43
  }
44
44
 
45
- @MainActor
46
45
  private var lifecycleAttached = false
47
46
 
48
- @MainActor
49
47
  private var lifecycleTasks = [Task<Void, Never>]()
50
48
 
51
- @MainActor
52
49
  private func attachLifecycleObservers() {
53
50
  if lifecycleAttached { return }
54
51
  lifecycleAttached = true
@@ -83,7 +80,6 @@ GMSIndoorDisplayDelegate {
83
80
  )
84
81
  }
85
82
 
86
- @MainActor
87
83
  private func detachLifecycleObservers() {
88
84
  if !lifecycleAttached { return }
89
85
  lifecycleAttached = false
@@ -95,34 +91,39 @@ GMSIndoorDisplayDelegate {
95
91
  fatalError("init(coder:) has not been implemented")
96
92
  }
97
93
 
98
- @MainActor
99
94
  func initMapView() {
100
- if mapViewInitialized { return }
101
- mapViewInitialized = true
102
- googleMapOptions.frame = bounds
95
+ onMain {
96
+ if self.mapViewInitialized { return }
97
+ self.mapViewInitialized = true
98
+ self.googleMapOptions.frame = self.bounds
103
99
 
104
- mapView = GMSMapView.init(options: googleMapOptions)
105
- mapView?.delegate = self
106
- mapView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
107
- mapView?.paddingAdjustmentBehavior = .never
108
- mapView.map { addSubview($0) }
109
- applyProps()
110
- initLocationCallbacks()
111
- onMapReady?(true)
100
+ self.mapView = GMSMapView.init(options: self.googleMapOptions)
101
+ self.mapView?.delegate = self
102
+ self.mapView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
103
+ self.mapView?.paddingAdjustmentBehavior = .never
104
+ self.mapView.map { self.addSubview($0) }
105
+ self.applyProps()
106
+ self.initLocationCallbacks()
107
+ self.onMapReady?(true)
108
+ }
112
109
  }
113
110
 
114
- @MainActor
115
111
  private func initLocationCallbacks() {
116
112
  locationHandler.onUpdate = { [weak self] loc in
117
- guard let self = self else { return }
118
- self.onLocationUpdate?(loc.toRnLocation())
113
+ onMain { [weak self] in
114
+ guard let self = self else { return }
115
+ self.onLocationUpdate?(loc.toRnLocation())
116
+ }
119
117
  }
118
+
120
119
  locationHandler.onError = { [weak self] error in
121
- self?.onLocationError?(error)
120
+ onMain { [weak self] in
121
+ guard let self = self else { return }
122
+ self.onLocationError?(error)
123
+ }
122
124
  }
123
125
  }
124
126
 
125
- @MainActor
126
127
  private func applyProps() {
127
128
  ({ self.uiSettings = self.uiSettings })()
128
129
  ({ self.mapPadding = self.mapPadding })()
@@ -176,110 +177,124 @@ GMSIndoorDisplayDelegate {
176
177
  }
177
178
  }
178
179
 
179
- @MainActor
180
180
  var currentCamera: GMSCameraPosition? {
181
- mapView?.camera
181
+ return mapView?.camera
182
182
  }
183
183
 
184
- @MainActor
185
184
  var googleMapOptions: GMSMapViewOptions = GMSMapViewOptions()
186
185
 
187
- @MainActor
188
186
  var uiSettings: RNMapUiSettings? {
189
187
  didSet {
190
- mapView?.settings.setAllGesturesEnabled(
191
- uiSettings?.allGesturesEnabled ?? true
192
- )
193
- mapView?.settings.compassButton = uiSettings?.compassEnabled ?? false
194
- mapView?.settings.indoorPicker =
195
- uiSettings?.indoorLevelPickerEnabled ?? false
196
- mapView?.settings.myLocationButton =
197
- uiSettings?.myLocationButtonEnabled ?? false
198
- mapView?.settings.rotateGestures = uiSettings?.rotateEnabled ?? true
199
- mapView?.settings.scrollGestures = uiSettings?.scrollEnabled ?? true
200
- mapView?.settings.allowScrollGesturesDuringRotateOrZoom =
201
- uiSettings?.scrollDuringRotateOrZoomEnabled ?? true
202
- mapView?.settings.tiltGestures = uiSettings?.tiltEnabled ?? true
203
- mapView?.settings.zoomGestures = uiSettings?.zoomGesturesEnabled ?? true
188
+ onMain {
189
+ self.mapView?.settings.setAllGesturesEnabled(
190
+ self.uiSettings?.allGesturesEnabled ?? true
191
+ )
192
+ self.mapView?.settings.compassButton =
193
+ self.uiSettings?.compassEnabled ?? false
194
+ self.mapView?.settings.indoorPicker =
195
+ self.uiSettings?.indoorLevelPickerEnabled ?? false
196
+ self.mapView?.settings.myLocationButton =
197
+ self.uiSettings?.myLocationButtonEnabled ?? false
198
+ self.mapView?.settings.rotateGestures =
199
+ self.uiSettings?.rotateEnabled ?? true
200
+ self.mapView?.settings.scrollGestures =
201
+ self.uiSettings?.scrollEnabled ?? true
202
+ self.mapView?.settings.allowScrollGesturesDuringRotateOrZoom =
203
+ self.uiSettings?.scrollDuringRotateOrZoomEnabled ?? true
204
+ self.mapView?.settings.tiltGestures =
205
+ self.uiSettings?.tiltEnabled ?? true
206
+ self.mapView?.settings.zoomGestures =
207
+ self.uiSettings?.zoomGesturesEnabled ?? true
208
+ }
204
209
  }
205
210
  }
206
211
 
207
- @MainActor
208
212
  var myLocationEnabled: Bool? {
209
213
  didSet {
210
- mapView?.isMyLocationEnabled = myLocationEnabled ?? false
214
+ onMain {
215
+ self.mapView?.isMyLocationEnabled = self.myLocationEnabled ?? false
216
+ }
211
217
  }
212
218
  }
213
219
 
214
- @MainActor
215
220
  var buildingEnabled: Bool? {
216
221
  didSet {
217
- mapView?.isBuildingsEnabled = buildingEnabled ?? false
222
+ onMain {
223
+ self.mapView?.isBuildingsEnabled = self.buildingEnabled ?? false
224
+ }
218
225
  }
219
226
  }
220
227
 
221
- @MainActor
222
228
  var trafficEnabled: Bool? {
223
229
  didSet {
224
- mapView?.isTrafficEnabled = trafficEnabled ?? false
230
+ onMain {
231
+ self.mapView?.isTrafficEnabled = self.trafficEnabled ?? false
232
+ }
225
233
  }
226
234
  }
227
235
 
228
- @MainActor
229
236
  var indoorEnabled: Bool? {
230
237
  didSet {
231
- mapView?.isIndoorEnabled = indoorEnabled ?? false
232
- mapView?.indoorDisplay.delegate = indoorEnabled == true ? self : nil
238
+ onMain {
239
+ self.mapView?.isIndoorEnabled = self.indoorEnabled ?? false
240
+ self.mapView?.indoorDisplay.delegate =
241
+ self.indoorEnabled == true ? self : nil
242
+ }
233
243
  }
234
244
  }
235
245
 
236
- @MainActor
237
246
  var customMapStyle: GMSMapStyle? {
238
247
  didSet {
239
- mapView?.mapStyle = customMapStyle
248
+ onMain {
249
+ self.mapView?.mapStyle = self.customMapStyle
250
+ }
240
251
  }
241
252
  }
242
253
 
243
- @MainActor
244
254
  var userInterfaceStyle: UIUserInterfaceStyle? {
245
255
  didSet {
246
- mapView?.overrideUserInterfaceStyle = userInterfaceStyle ?? .unspecified
256
+ onMain {
257
+ self.mapView?.overrideUserInterfaceStyle =
258
+ self.userInterfaceStyle ?? .unspecified
259
+ }
247
260
  }
248
261
  }
249
262
 
250
- @MainActor
251
263
  var mapZoomConfig: RNMapZoomConfig? {
252
264
  didSet {
253
- mapView?.setMinZoom(
254
- Float(mapZoomConfig?.min ?? 2),
255
- maxZoom: Float(mapZoomConfig?.max ?? 21)
256
- )
265
+ onMain {
266
+ self.mapView?.setMinZoom(
267
+ Float(self.mapZoomConfig?.min ?? 2),
268
+ maxZoom: Float(self.mapZoomConfig?.max ?? 21)
269
+ )
270
+ }
257
271
  }
258
272
  }
259
273
 
260
- @MainActor
261
274
  var mapPadding: RNMapPadding? {
262
275
  didSet {
263
- mapView?.padding =
264
- mapPadding.map {
265
- UIEdgeInsets(
266
- top: $0.top,
267
- left: $0.left,
268
- bottom: $0.bottom,
269
- right: $0.right
270
- )
271
- } ?? .zero
276
+ onMain {
277
+ self.mapView?.padding =
278
+ self.mapPadding.map {
279
+ UIEdgeInsets(
280
+ top: $0.top,
281
+ left: $0.left,
282
+ bottom: $0.bottom,
283
+ right: $0.right
284
+ )
285
+ } ?? .zero
286
+ }
272
287
  }
273
288
  }
274
289
 
275
- @MainActor
276
290
  var mapType: GMSMapViewType? {
277
291
  didSet {
278
- mapView?.mapType = mapType ?? .normal
292
+ onMain {
293
+ self.mapView?.mapType = self.mapType ?? .normal
294
+ }
279
295
  }
280
296
  }
281
297
 
282
- @MainActor
283
298
  var locationConfig: RNLocationConfig? {
284
299
  didSet {
285
300
  locationHandler.updateConfig(
@@ -317,7 +332,6 @@ GMSIndoorDisplayDelegate {
317
332
  var onCameraChange: ((RNRegion, RNCamera, Bool) -> Void)?
318
333
  var onCameraChangeComplete: ((RNRegion, RNCamera, Bool) -> Void)?
319
334
 
320
- @MainActor
321
335
  func showMarkerInfoWindow(id: String) {
322
336
  onMain {
323
337
  guard let marker = self.markersById[id] else { return }
@@ -326,7 +340,6 @@ GMSIndoorDisplayDelegate {
326
340
  }
327
341
  }
328
342
 
329
- @MainActor
330
343
  func hideMarkerInfoWindow(id: String) {
331
344
  onMain {
332
345
  guard let marker = self.markersById[id] else { return }
@@ -336,81 +349,87 @@ GMSIndoorDisplayDelegate {
336
349
  }
337
350
  }
338
351
 
339
- @MainActor
340
352
  func setCamera(camera: GMSCameraPosition, animated: Bool, durationMs: Double) {
341
- if animated {
342
- withCATransaction(
343
- disableActions: false,
344
- duration: durationMs / 1000.0
345
- ) {
346
- self.mapView?.animate(to: camera)
353
+ onMain {
354
+ if animated {
355
+ withCATransaction(
356
+ disableActions: false,
357
+ duration: durationMs / 1000.0
358
+ ) {
359
+ self.mapView?.animate(to: camera)
360
+ }
361
+ } else {
362
+ let update = GMSCameraUpdate.setCamera(camera)
363
+ self.mapView?.moveCamera(update)
347
364
  }
348
- } else {
349
- let update = GMSCameraUpdate.setCamera(camera)
350
- mapView?.moveCamera(update)
351
365
  }
352
366
  }
353
367
 
354
- @MainActor
355
368
  func setCameraToCoordinates(
356
369
  coordinates: [RNLatLng],
357
370
  padding: RNMapPadding,
358
371
  animated: Bool,
359
372
  durationMs: Double
360
373
  ) {
361
- guard let firstCoordinates = coordinates.first else {
362
- return
363
- }
364
- var bounds = GMSCoordinateBounds(
365
- coordinate: firstCoordinates.toCLLocationCoordinate2D(),
366
- coordinate: firstCoordinates.toCLLocationCoordinate2D()
367
- )
374
+ onMain {
375
+ guard let firstCoordinates = coordinates.first else {
376
+ return
377
+ }
378
+ var bounds = GMSCoordinateBounds(
379
+ coordinate: firstCoordinates.toCLLocationCoordinate2D(),
380
+ coordinate: firstCoordinates.toCLLocationCoordinate2D()
381
+ )
368
382
 
369
- for coord in coordinates.dropFirst() {
370
- bounds = bounds.includingCoordinate(coord.toCLLocationCoordinate2D())
371
- }
383
+ for coordinate in coordinates.dropFirst() {
384
+ bounds = bounds.includingCoordinate(
385
+ coordinate.toCLLocationCoordinate2D()
386
+ )
387
+ }
372
388
 
373
- let insets = UIEdgeInsets(
374
- top: padding.top,
375
- left: padding.left,
376
- bottom: padding.bottom,
377
- right: padding.right
378
- )
389
+ let insets = UIEdgeInsets(
390
+ top: padding.top,
391
+ left: padding.left,
392
+ bottom: padding.bottom,
393
+ right: padding.right
394
+ )
379
395
 
380
- let update = GMSCameraUpdate.fit(bounds, with: insets)
381
- if animated {
382
- withCATransaction(
383
- disableActions: false,
384
- duration: durationMs / 1000.0
385
- ) {
386
- self.mapView?.animate(with: update)
396
+ let update = GMSCameraUpdate.fit(bounds, with: insets)
397
+
398
+ if animated {
399
+ withCATransaction(
400
+ disableActions: false,
401
+ duration: durationMs / 1000.0
402
+ ) {
403
+ self.mapView?.animate(with: update)
404
+ }
405
+ } else {
406
+ self.mapView?.moveCamera(update)
387
407
  }
388
- } else {
389
- mapView?.moveCamera(update)
390
408
  }
391
409
  }
392
410
 
393
- @MainActor
394
411
  func setCameraBounds(_ bounds: GMSCoordinateBounds?) {
395
- mapView?.cameraTargetBounds = bounds
412
+ onMain {
413
+ self.mapView?.cameraTargetBounds = bounds
414
+ }
396
415
  }
397
416
 
398
- @MainActor
399
417
  func animateToBounds(
400
418
  _ bounds: GMSCoordinateBounds,
401
419
  padding: Double,
402
420
  durationMs: Double,
403
421
  lockBounds: Bool
404
422
  ) {
405
- if lockBounds {
406
- mapView?.cameraTargetBounds = bounds
407
- }
423
+ onMain {
424
+ if lockBounds {
425
+ self.mapView?.cameraTargetBounds = bounds
426
+ }
408
427
 
409
- let update = GMSCameraUpdate.fit(bounds, withPadding: CGFloat(padding))
410
- mapView?.animate(with: update)
428
+ let update = GMSCameraUpdate.fit(bounds, withPadding: CGFloat(padding))
429
+ self.mapView?.animate(with: update)
430
+ }
411
431
  }
412
432
 
413
- @MainActor
414
433
  func snapshot(
415
434
  size: CGSize?,
416
435
  format: String,
@@ -420,7 +439,7 @@ GMSIndoorDisplayDelegate {
420
439
  ) -> NitroModules.Promise<String?> {
421
440
  let promise = Promise<String?>()
422
441
 
423
- onMainAsync {
442
+ onMain {
424
443
  guard let mapView = self.mapView else {
425
444
  promise.resolve(withResult: nil)
426
445
  return
@@ -447,256 +466,289 @@ GMSIndoorDisplayDelegate {
447
466
  return promise
448
467
  }
449
468
 
450
- @MainActor
451
469
  func addMarker(id: String, marker: GMSMarker) {
452
- if mapView == nil {
453
- pendingMarkers.append((id, marker))
454
- return
470
+ onMain {
471
+ if self.mapView == nil {
472
+ self.pendingMarkers.append((id, marker))
473
+ return
474
+ }
475
+ self.markersById.removeValue(forKey: id).map { $0.map = nil }
476
+ self.addMarkerInternal(id: id, marker: marker)
455
477
  }
456
- markersById.removeValue(forKey: id).map { $0.map = nil }
457
- addMarkerInternal(id: id, marker: marker)
458
478
  }
459
479
 
460
- @MainActor
461
480
  private func addMarkerInternal(id: String, marker: GMSMarker) {
462
- marker.map = mapView
463
- markersById[id] = marker
481
+ onMain {
482
+ marker.map = self.mapView
483
+ self.markersById[id] = marker
484
+ }
464
485
  }
465
486
 
466
- @MainActor
467
487
  func updateMarker(id: String, block: @escaping (GMSMarker) -> Void) {
468
- markersById[id].map {
469
- block($0)
470
- if let mapView, mapView.selectedMarker == $0 {
471
- mapView.selectedMarker = nil
472
- mapView.selectedMarker = $0
488
+ onMain {
489
+ self.markersById[id].map {
490
+ block($0)
491
+ if let mapView = self.mapView, mapView.selectedMarker == $0 {
492
+ mapView.selectedMarker = nil
493
+ mapView.selectedMarker = $0
494
+ }
473
495
  }
474
496
  }
475
497
  }
476
498
 
477
- @MainActor
478
499
  func removeMarker(id: String) {
479
- markersById.removeValue(forKey: id).map {
480
- $0.icon = nil
481
- $0.map = nil
500
+ onMain {
501
+ self.markersById.removeValue(forKey: id).map {
502
+ $0.icon = nil
503
+ $0.map = nil
504
+ }
482
505
  }
483
506
  }
484
507
 
485
- @MainActor
486
508
  func clearMarkers() {
487
- markersById.values.forEach { $0.map = nil }
488
- markersById.removeAll()
489
- pendingMarkers.removeAll()
509
+ onMain {
510
+ self.markersById.values.forEach { $0.map = nil }
511
+ self.markersById.removeAll()
512
+ self.pendingMarkers.removeAll()
513
+ }
490
514
  }
491
515
 
492
- @MainActor
493
516
  func addPolyline(id: String, polyline: GMSPolyline) {
494
- if mapView == nil {
495
- pendingPolylines.append((id, polyline))
496
- return
517
+ onMain {
518
+ if self.mapView == nil {
519
+ self.pendingPolylines.append((id, polyline))
520
+ return
521
+ }
522
+ self.polylinesById.removeValue(forKey: id).map { $0.map = nil }
523
+ self.addPolylineInternal(id: id, polyline: polyline)
497
524
  }
498
- polylinesById.removeValue(forKey: id).map { $0.map = nil }
499
- addPolylineInternal(id: id, polyline: polyline)
500
525
  }
501
526
 
502
- @MainActor
503
527
  private func addPolylineInternal(id: String, polyline: GMSPolyline) {
504
- polyline.tagData = PolylineTag(id: id)
505
- polyline.map = mapView
506
- polylinesById[id] = polyline
528
+ onMain {
529
+ polyline.tagData = PolylineTag(id: id)
530
+ polyline.map = self.mapView
531
+ self.polylinesById[id] = polyline
532
+ }
507
533
  }
508
534
 
509
- @MainActor
510
535
  func updatePolyline(id: String, block: @escaping (GMSPolyline) -> Void) {
511
- polylinesById[id].map { block($0) }
536
+ onMain {
537
+ self.polylinesById[id].map { block($0) }
538
+ }
512
539
  }
513
540
 
514
- @MainActor
515
541
  func removePolyline(id: String) {
516
- polylinesById.removeValue(forKey: id).map { $0.map = nil }
542
+ onMain {
543
+ self.polylinesById.removeValue(forKey: id).map { $0.map = nil }
544
+ }
517
545
  }
518
546
 
519
- @MainActor
520
547
  func clearPolylines() {
521
- polylinesById.values.forEach { $0.map = nil }
522
- polylinesById.removeAll()
523
- pendingPolylines.removeAll()
548
+ onMain {
549
+ self.polylinesById.values.forEach { $0.map = nil }
550
+ self.polylinesById.removeAll()
551
+ self.pendingPolylines.removeAll()
552
+ }
524
553
  }
525
554
 
526
- @MainActor
527
555
  func addPolygon(id: String, polygon: GMSPolygon) {
528
- if mapView == nil {
529
- pendingPolygons.append((id, polygon))
530
- return
556
+ onMain {
557
+ if self.mapView == nil {
558
+ self.pendingPolygons.append((id, polygon))
559
+ return
560
+ }
561
+ self.polygonsById.removeValue(forKey: id).map { $0.map = nil }
562
+ self.addPolygonInternal(id: id, polygon: polygon)
531
563
  }
532
- polygonsById.removeValue(forKey: id).map { $0.map = nil }
533
- addPolygonInternal(id: id, polygon: polygon)
534
564
  }
535
565
 
536
- @MainActor
537
566
  private func addPolygonInternal(id: String, polygon: GMSPolygon) {
538
- polygon.tagData = PolygonTag(id: id)
539
- polygon.map = mapView
540
- polygonsById[id] = polygon
567
+ onMain {
568
+ polygon.tagData = PolygonTag(id: id)
569
+ polygon.map = self.mapView
570
+ self.polygonsById[id] = polygon
571
+ }
541
572
  }
542
573
 
543
- @MainActor
544
574
  func updatePolygon(id: String, block: @escaping (GMSPolygon) -> Void) {
545
- polygonsById[id].map { block($0) }
575
+ onMain {
576
+ self.polygonsById[id].map { block($0) }
577
+ }
546
578
  }
547
579
 
548
- @MainActor
549
580
  func removePolygon(id: String) {
550
- polygonsById.removeValue(forKey: id).map { $0.map = nil }
581
+ onMain {
582
+ self.polygonsById.removeValue(forKey: id).map { $0.map = nil }
583
+ }
551
584
  }
552
585
 
553
- @MainActor
554
586
  func clearPolygons() {
555
- polygonsById.values.forEach { $0.map = nil }
556
- polygonsById.removeAll()
557
- pendingPolygons.removeAll()
587
+ onMain {
588
+ self.polygonsById.values.forEach { $0.map = nil }
589
+ self.polygonsById.removeAll()
590
+ self.pendingPolygons.removeAll()
591
+ }
558
592
  }
559
593
 
560
- @MainActor
561
594
  func addCircle(id: String, circle: GMSCircle) {
562
- if mapView == nil {
563
- pendingCircles.append((id, circle))
564
- return
595
+ onMain {
596
+ if self.mapView == nil {
597
+ self.pendingCircles.append((id, circle))
598
+ return
599
+ }
600
+ self.circlesById.removeValue(forKey: id).map { $0.map = nil }
601
+ self.addCircleInternal(id: id, circle: circle)
565
602
  }
566
- circlesById.removeValue(forKey: id).map { $0.map = nil }
567
- addCircleInternal(id: id, circle: circle)
568
603
  }
569
604
 
570
- @MainActor
571
605
  private func addCircleInternal(id: String, circle: GMSCircle) {
572
- circle.tagData = CircleTag(id: id)
573
- circle.map = mapView
574
- circlesById[id] = circle
606
+ onMain {
607
+ circle.tagData = CircleTag(id: id)
608
+ circle.map = self.mapView
609
+ self.circlesById[id] = circle
610
+ }
575
611
  }
576
612
 
577
- @MainActor
578
613
  func updateCircle(id: String, block: @escaping (GMSCircle) -> Void) {
579
- circlesById[id].map { block($0) }
614
+ onMain {
615
+ self.circlesById[id].map { block($0) }
616
+ }
580
617
  }
581
618
 
582
- @MainActor
583
619
  func removeCircle(id: String) {
584
- circlesById.removeValue(forKey: id).map { $0.map = nil }
620
+ onMain {
621
+ self.circlesById.removeValue(forKey: id).map { $0.map = nil }
622
+ }
585
623
  }
586
624
 
587
- @MainActor
588
625
  func clearCircles() {
589
- circlesById.values.forEach { $0.map = nil }
590
- circlesById.removeAll()
591
- pendingCircles.removeAll()
626
+ onMain {
627
+ self.circlesById.values.forEach { $0.map = nil }
628
+ self.circlesById.removeAll()
629
+ self.pendingCircles.removeAll()
630
+ }
592
631
  }
593
632
 
594
- @MainActor
595
633
  func addHeatmap(id: String, heatmap: GMUHeatmapTileLayer) {
596
- if mapView == nil {
597
- pendingHeatmaps.append((id, heatmap))
598
- return
634
+ onMain {
635
+ if self.mapView == nil {
636
+ self.pendingHeatmaps.append((id, heatmap))
637
+ return
638
+ }
639
+ self.heatmapsById.removeValue(forKey: id).map { $0.map = nil }
640
+ self.addHeatmapInternal(id: id, heatmap: heatmap)
599
641
  }
600
- heatmapsById.removeValue(forKey: id).map { $0.map = nil }
601
- addHeatmapInternal(id: id, heatmap: heatmap)
602
642
  }
603
643
 
604
- @MainActor
605
644
  private func addHeatmapInternal(id: String, heatmap: GMUHeatmapTileLayer) {
606
- heatmap.map = mapView
607
- heatmapsById[id] = heatmap
645
+ onMain {
646
+ heatmap.map = self.mapView
647
+ self.heatmapsById[id] = heatmap
648
+ }
608
649
  }
609
650
 
610
- @MainActor
611
651
  func removeHeatmap(id: String) {
612
- heatmapsById.removeValue(forKey: id).map {
613
- $0.clearTileCache()
614
- $0.map = nil
652
+ onMain {
653
+ self.heatmapsById.removeValue(forKey: id).map {
654
+ $0.clearTileCache()
655
+ $0.map = nil
656
+ }
615
657
  }
616
658
  }
617
659
 
618
- @MainActor
619
660
  func clearHeatmaps() {
620
- heatmapsById.values.forEach {
621
- $0.clearTileCache()
622
- $0.map = nil
661
+ onMain {
662
+ self.heatmapsById.values.forEach {
663
+ $0.clearTileCache()
664
+ $0.map = nil
665
+ }
666
+ self.heatmapsById.removeAll()
667
+ self.pendingHeatmaps.removeAll()
623
668
  }
624
- heatmapsById.removeAll()
625
- pendingHeatmaps.removeAll()
626
669
  }
627
670
 
628
- @MainActor
629
671
  func addKmlLayer(id: String, kmlString: String) {
630
- if mapView == nil {
631
- pendingKmlLayers.append((id, kmlString))
632
- return
672
+ onMain {
673
+ if self.mapView == nil {
674
+ self.pendingKmlLayers.append((id, kmlString))
675
+ return
676
+ }
677
+ self.kmlLayerById.removeValue(forKey: id).map { $0.clear() }
678
+ self.addKmlLayerInternal(id: id, kmlString: kmlString)
633
679
  }
634
- kmlLayerById.removeValue(forKey: id).map { $0.clear() }
635
- addKmlLayerInternal(id: id, kmlString: kmlString)
636
680
  }
637
681
 
638
- @MainActor
639
682
  private func addKmlLayerInternal(id: String, kmlString: String) {
640
- guard let data = kmlString.data(using: .utf8) else { return }
641
- let parser = GMUKMLParser(data: data)
642
- parser.parse()
643
- mapView.map { mapView in
644
- let renderer = GMUGeometryRenderer(
645
- map: mapView,
646
- geometries: parser.placemarks
647
- )
648
- renderer.render()
649
- kmlLayerById[id] = renderer
683
+ onMain {
684
+ guard let data = kmlString.data(using: .utf8) else { return }
685
+ let parser = GMUKMLParser(data: data)
686
+ parser.parse()
687
+
688
+ self.mapView.map { mapView in
689
+ let renderer = GMUGeometryRenderer(
690
+ map: mapView,
691
+ geometries: parser.placemarks
692
+ )
693
+ renderer.render()
694
+ self.kmlLayerById[id] = renderer
695
+ }
650
696
  }
651
697
  }
652
698
 
653
- @MainActor
654
699
  func removeKmlLayer(id: String) {
655
- kmlLayerById.removeValue(forKey: id).map { $0.clear() }
700
+ onMain {
701
+ self.kmlLayerById.removeValue(forKey: id).map { $0.clear() }
702
+ }
656
703
  }
657
704
 
658
- @MainActor
659
705
  func clearKmlLayers() {
660
- kmlLayerById.values.forEach { $0.clear() }
661
- kmlLayerById.removeAll()
662
- pendingKmlLayers.removeAll()
706
+ onMain {
707
+ self.kmlLayerById.values.forEach { $0.clear() }
708
+ self.kmlLayerById.removeAll()
709
+ self.pendingKmlLayers.removeAll()
710
+ }
663
711
  }
664
712
 
665
- @MainActor
666
713
  func addUrlTileOverlay(id: String, urlTileOverlay: GMSURLTileLayer) {
667
- if mapView == nil {
668
- pendingUrlTileOverlays.append((id, urlTileOverlay))
669
- return
714
+ onMain {
715
+ if self.mapView == nil {
716
+ self.pendingUrlTileOverlays.append((id, urlTileOverlay))
717
+ return
718
+ }
719
+ self.urlTileOverlays.removeValue(forKey: id).map { $0.map = nil }
720
+ self.addUrlTileOverlayInternal(id: id, urlTileOverlay: urlTileOverlay)
670
721
  }
671
- urlTileOverlays.removeValue(forKey: id).map { $0.map = nil }
672
- addUrlTileOverlayInternal(id: id, urlTileOverlay: urlTileOverlay)
673
722
  }
674
723
 
675
- @MainActor
676
724
  private func addUrlTileOverlayInternal(
677
725
  id: String,
678
726
  urlTileOverlay: GMSURLTileLayer
679
727
  ) {
680
- urlTileOverlay.map = mapView
681
- urlTileOverlays[id] = urlTileOverlay
728
+ onMain {
729
+ urlTileOverlay.map = self.mapView
730
+ self.urlTileOverlays[id] = urlTileOverlay
731
+ }
682
732
  }
683
733
 
684
- @MainActor
685
734
  func removeUrlTileOverlay(id: String) {
686
- urlTileOverlays.removeValue(forKey: id).map {
687
- $0.clearTileCache()
688
- $0.map = nil
735
+ onMain {
736
+ self.urlTileOverlays.removeValue(forKey: id).map {
737
+ $0.clearTileCache()
738
+ $0.map = nil
739
+ }
689
740
  }
690
741
  }
691
742
 
692
- @MainActor
693
743
  func clearUrlTileOverlay() {
694
- urlTileOverlays.values.forEach {
695
- $0.clearTileCache()
696
- $0.map = nil
744
+ onMain {
745
+ self.urlTileOverlays.values.forEach {
746
+ $0.clearTileCache()
747
+ $0.map = nil
748
+ }
749
+ self.urlTileOverlays.removeAll()
750
+ self.pendingUrlTileOverlays.removeAll()
697
751
  }
698
- urlTileOverlays.removeAll()
699
- pendingUrlTileOverlays.removeAll()
700
752
  }
701
753
 
702
754
  func deinitInternal() {
@@ -714,6 +766,11 @@ GMSIndoorDisplayDelegate {
714
766
  self.clearKmlLayers()
715
767
  self.clearUrlTileOverlay()
716
768
  self.mapView?.clear()
769
+ self.mapView?.isTrafficEnabled = false
770
+ self.mapView?.isIndoorEnabled = false
771
+ self.mapView?.isMyLocationEnabled = false
772
+ self.mapView?.cameraTargetBounds = nil
773
+ self.mapView?.layer.removeAllAnimations()
717
774
  self.mapView?.indoorDisplay.delegate = nil
718
775
  self.mapView?.delegate = nil
719
776
  self.mapView = nil
@@ -752,11 +809,14 @@ GMSIndoorDisplayDelegate {
752
809
 
753
810
  func mapViewDidFinishTileRendering(_ mapView: GMSMapView) {
754
811
  guard !mapViewLoaded else { return }
755
- mapViewLoaded = true
756
- let visibleRegion = mapView.projection.visibleRegion().toRNRegion()
757
- let camera = mapView.camera.toRNCamera()
812
+ onMain {
813
+ self.mapViewLoaded = true
758
814
 
759
- self.onMapLoaded?(visibleRegion, camera)
815
+ let visibleRegion = mapView.projection.visibleRegion().toRNRegion()
816
+ let camera = mapView.camera.toRNCamera()
817
+
818
+ self.onMapLoaded?(visibleRegion, camera)
819
+ }
760
820
  }
761
821
 
762
822
  func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {