react-native-google-maps-plus 1.3.0 → 1.4.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.
Files changed (119) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +50 -161
  3. package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +38 -36
  4. package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +33 -9
  5. package/android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt +73 -18
  6. package/android/src/main/java/com/rngooglemapsplus/MapPolygonBuilder.kt +59 -12
  7. package/android/src/main/java/com/rngooglemapsplus/MapPolylineBuilder.kt.kt +47 -12
  8. package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +12 -9
  9. package/android/src/main/java/com/rngooglemapsplus/extensions/CameraPositionExtension.kt +12 -0
  10. package/android/src/main/java/com/rngooglemapsplus/extensions/IntExtension.kt +28 -0
  11. package/android/src/main/java/com/rngooglemapsplus/extensions/LatLngBounds.kt +15 -0
  12. package/android/src/main/java/com/rngooglemapsplus/extensions/LatLngExtension.kt +6 -0
  13. package/android/src/main/java/com/rngooglemapsplus/extensions/LocationExtension.kt +59 -0
  14. package/android/src/main/java/com/rngooglemapsplus/extensions/RNCameraExtension.kt +1 -2
  15. package/android/src/main/java/com/rngooglemapsplus/extensions/RNLatLngExtension.kt +6 -0
  16. package/android/src/main/java/com/rngooglemapsplus/extensions/RNMarkerExtension.kt +8 -0
  17. package/android/src/main/java/com/rngooglemapsplus/extensions/RNPolygonExtension.kt +2 -0
  18. package/android/src/main/java/com/rngooglemapsplus/extensions/RNPolylineExtension.kt +1 -0
  19. package/ios/GoogleMapViewImpl.swift +39 -180
  20. package/ios/LocationHandler.swift +5 -13
  21. package/ios/MapCircleBuilder.swift +30 -18
  22. package/ios/MapHelper.swift +20 -0
  23. package/ios/MapMarkerBuilder.swift +105 -86
  24. package/ios/MapPolygonBuilder.swift +62 -13
  25. package/ios/MapPolylineBuilder.swift +33 -15
  26. package/ios/RNGoogleMapsPlusView.swift +15 -9
  27. package/ios/extensions/CLError+Extension.swift +14 -0
  28. package/ios/extensions/CLLocation+Extension.swift +27 -0
  29. package/ios/extensions/CLLocationCoordinate2D+Extension.swift +7 -0
  30. package/ios/extensions/GMSCameraPosition+Extension.swift +12 -0
  31. package/ios/extensions/GMSCoordinateBounds+Extension.swift +19 -0
  32. package/ios/extensions/RNLatLng+Extension.swift +7 -0
  33. package/ios/extensions/RNMarker+Extension.swift +7 -3
  34. package/ios/extensions/RNPolygon+Extension.swift.swift +16 -1
  35. package/ios/extensions/RNPolyline+Extension.swift.swift +1 -0
  36. package/lib/module/GoogleMapsPlus.js +7 -0
  37. package/lib/module/GoogleMapsPlus.js.map +1 -0
  38. package/lib/module/index.js +3 -5
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/types.js.map +1 -1
  41. package/lib/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +44 -0
  42. package/lib/typescript/src/GoogleMapsPlus.d.ts +5 -0
  43. package/lib/typescript/src/GoogleMapsPlus.d.ts.map +1 -0
  44. package/lib/typescript/src/index.d.ts +3 -3
  45. package/lib/typescript/src/index.d.ts.map +1 -1
  46. package/lib/typescript/src/types.d.ts +33 -0
  47. package/lib/typescript/src/types.d.ts.map +1 -1
  48. package/nitrogen/generated/android/c++/JFunc_void_RNLocation.hpp +6 -0
  49. package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +12 -0
  50. package/nitrogen/generated/android/c++/JRNLocation.hpp +32 -2
  51. package/nitrogen/generated/android/c++/JRNLocationAndroid.hpp +82 -0
  52. package/nitrogen/generated/android/c++/JRNLocationIOS.hpp +77 -0
  53. package/nitrogen/generated/android/c++/JRNMarker.hpp +8 -0
  54. package/nitrogen/generated/android/c++/JRNPolygon.hpp +29 -2
  55. package/nitrogen/generated/android/c++/JRNPolygonHole.hpp +72 -0
  56. package/nitrogen/generated/android/c++/JRNPolyline.hpp +4 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocation.kt +19 -1
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationAndroid.kt +50 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationIOS.kt +47 -0
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarker.kt +6 -0
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolygon.kt +7 -1
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolygonHole.kt +29 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNPolyline.kt +3 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt +8 -3
  65. package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.cpp +16 -16
  66. package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +87 -20
  67. package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +9 -0
  68. package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +12 -3
  69. package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +8 -0
  70. package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +7 -56
  71. package/nitrogen/generated/ios/swift/RNCamera.swift +1 -8
  72. package/nitrogen/generated/ios/swift/RNHeatmap.swift +1 -8
  73. package/nitrogen/generated/ios/swift/RNHeatmapGradient.swift +11 -15
  74. package/nitrogen/generated/ios/swift/RNInitialProps.swift +1 -8
  75. package/nitrogen/generated/ios/swift/RNLocation.swift +92 -2
  76. package/nitrogen/generated/ios/swift/RNLocationAndroid.swift +215 -0
  77. package/nitrogen/generated/ios/swift/RNLocationConfig.swift +2 -16
  78. package/nitrogen/generated/ios/swift/RNLocationIOS.swift +185 -0
  79. package/nitrogen/generated/ios/swift/RNMarker.swift +47 -15
  80. package/nitrogen/generated/ios/swift/RNPolygon.swift +66 -1
  81. package/nitrogen/generated/ios/swift/RNPolygonHole.swift +47 -0
  82. package/nitrogen/generated/ios/swift/RNPolyline.swift +24 -1
  83. package/nitrogen/generated/ios/swift/RNSnapshotOptions.swift +1 -8
  84. package/nitrogen/generated/shared/c++/RNAndroidLocationConfig.hpp +8 -0
  85. package/nitrogen/generated/shared/c++/RNCamera.hpp +8 -0
  86. package/nitrogen/generated/shared/c++/RNCircle.hpp +8 -0
  87. package/nitrogen/generated/shared/c++/RNHeatmap.hpp +8 -0
  88. package/nitrogen/generated/shared/c++/RNHeatmapGradient.hpp +8 -0
  89. package/nitrogen/generated/shared/c++/RNHeatmapPoint.hpp +8 -0
  90. package/nitrogen/generated/shared/c++/RNIOSLocationConfig.hpp +8 -0
  91. package/nitrogen/generated/shared/c++/RNIndoorBuilding.hpp +8 -0
  92. package/nitrogen/generated/shared/c++/RNIndoorLevel.hpp +8 -0
  93. package/nitrogen/generated/shared/c++/RNInitialProps.hpp +8 -0
  94. package/nitrogen/generated/shared/c++/RNKMLayer.hpp +8 -0
  95. package/nitrogen/generated/shared/c++/RNLatLng.hpp +8 -0
  96. package/nitrogen/generated/shared/c++/RNLatLngBounds.hpp +8 -0
  97. package/nitrogen/generated/shared/c++/RNLocation.hpp +41 -2
  98. package/nitrogen/generated/shared/c++/RNLocationAndroid.hpp +104 -0
  99. package/nitrogen/generated/shared/c++/RNLocationConfig.hpp +8 -0
  100. package/nitrogen/generated/shared/c++/RNLocationIOS.hpp +99 -0
  101. package/nitrogen/generated/shared/c++/RNLocationPermissionResult.hpp +8 -0
  102. package/nitrogen/generated/shared/c++/RNMapPadding.hpp +8 -0
  103. package/nitrogen/generated/shared/c++/RNMapUiSettings.hpp +8 -0
  104. package/nitrogen/generated/shared/c++/RNMapZoomConfig.hpp +8 -0
  105. package/nitrogen/generated/shared/c++/RNMarker.hpp +17 -1
  106. package/nitrogen/generated/shared/c++/RNMarkerSvg.hpp +8 -0
  107. package/nitrogen/generated/shared/c++/RNPolygon.hpp +21 -2
  108. package/nitrogen/generated/shared/c++/RNPolygonHole.hpp +77 -0
  109. package/nitrogen/generated/shared/c++/RNPolyline.hpp +13 -1
  110. package/nitrogen/generated/shared/c++/RNPosition.hpp +8 -0
  111. package/nitrogen/generated/shared/c++/RNRegion.hpp +8 -0
  112. package/nitrogen/generated/shared/c++/RNSize.hpp +8 -0
  113. package/nitrogen/generated/shared/c++/RNSnapshotOptions.hpp +8 -0
  114. package/package.json +9 -16
  115. package/src/GoogleMapsPlus.tsx +20 -0
  116. package/src/index.tsx +6 -14
  117. package/src/types.ts +36 -0
  118. package/lib/module/package.json +0 -1
  119. package/lib/typescript/package.json +0 -1
@@ -11,6 +11,7 @@ GMSIndoorDisplayDelegate {
11
11
  private var mapView: GMSMapView?
12
12
  private var initialized = false
13
13
  private var mapReady = false
14
+ private var deInitialized = false
14
15
 
15
16
  private var pendingMarkers: [(id: String, marker: GMSMarker)] = []
16
17
  private var pendingPolylines: [(id: String, polyline: GMSPolyline)] = []
@@ -28,7 +29,6 @@ GMSIndoorDisplayDelegate {
28
29
 
29
30
  private var cameraMoveReasonIsGesture: Bool = false
30
31
  private var lastSubmittedCameraPosition: GMSCameraPosition?
31
- private var lastSubmittedLocation: CLLocation?
32
32
 
33
33
  init(
34
34
  frame: CGRect = .zero,
@@ -62,23 +62,18 @@ GMSIndoorDisplayDelegate {
62
62
  }
63
63
 
64
64
  @MainActor
65
- func initMapView(mapId: String?, liteMode: Bool?, camera: GMSCameraPosition?) {
65
+ func initMapView(googleMapOptions: GMSMapViewOptions) {
66
66
  if initialized { return }
67
67
  initialized = true
68
- let options = GMSMapViewOptions()
69
- options.frame = bounds
68
+ googleMapOptions.frame = bounds
70
69
 
71
- mapId.map { options.mapID = GMSMapID(identifier: $0) }
72
- liteMode.map { _ in /* not supported */ }
73
- camera.map { options.camera = $0 }
74
-
75
- mapView = GMSMapView.init(options: options)
70
+ mapView = GMSMapView.init(options: googleMapOptions)
76
71
  mapView?.delegate = self
77
72
  mapView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
78
73
  mapView?.paddingAdjustmentBehavior = .never
79
74
  mapView.map { addSubview($0) }
75
+ applyProps()
80
76
  initLocationCallbacks()
81
- applyPending()
82
77
  onMapReady?(true)
83
78
  mapReady = true
84
79
  }
@@ -87,21 +82,7 @@ GMSIndoorDisplayDelegate {
87
82
  private func initLocationCallbacks() {
88
83
  locationHandler.onUpdate = { [weak self] loc in
89
84
  guard let self = self else { return }
90
- if self.lastSubmittedLocation?.coordinate.latitude
91
- != loc.coordinate.latitude
92
- || self.lastSubmittedLocation?.coordinate.longitude
93
- != loc.coordinate.longitude {
94
- self.onLocationUpdate?(
95
- RNLocation(
96
- RNLatLng(
97
- latitude: loc.coordinate.latitude,
98
- longitude: loc.coordinate.longitude
99
- ),
100
- loc.course
101
- )
102
- )
103
- }
104
- self.lastSubmittedLocation = loc
85
+ self.onLocationUpdate?(loc.toRnLocation())
105
86
  }
106
87
  locationHandler.onError = { [weak self] error in
107
88
  self?.onLocationError?(error)
@@ -110,55 +91,19 @@ GMSIndoorDisplayDelegate {
110
91
  }
111
92
 
112
93
  @MainActor
113
- private func applyPending() {
114
- mapPadding.map {
115
- mapView?.padding = UIEdgeInsets(
116
- top: $0.top,
117
- left: $0.left,
118
- bottom: $0.bottom,
119
- right: $0.right
120
- )
121
- }
122
-
123
- if let v = uiSettings {
124
- v.allGesturesEnabled.map { mapView?.settings.setAllGesturesEnabled($0) }
125
- v.compassEnabled.map { mapView?.settings.compassButton = $0 }
126
- v.indoorLevelPickerEnabled.map { mapView?.settings.indoorPicker = $0 }
127
- v.mapToolbarEnabled.map { _ in /* not supported */ }
128
- v.myLocationButtonEnabled.map { mapView?.settings.myLocationButton = $0 }
129
- v.rotateEnabled.map { mapView?.settings.rotateGestures = $0 }
130
- v.scrollEnabled.map { mapView?.settings.scrollGestures = $0 }
131
- v.scrollDuringRotateOrZoomEnabled.map {
132
- mapView?.settings.allowScrollGesturesDuringRotateOrZoom = $0
133
- }
134
- v.tiltEnabled.map { mapView?.settings.tiltGestures = $0 }
135
- v.zoomControlsEnabled.map { _ in /* not supported */ }
136
- v.zoomGesturesEnabled.map { mapView?.settings.zoomGestures = $0 }
137
- }
138
-
139
- myLocationEnabled.map { mapView?.isMyLocationEnabled = $0 }
140
- buildingEnabled.map { mapView?.isBuildingsEnabled = $0 }
141
- trafficEnabled.map { mapView?.isTrafficEnabled = $0 }
142
- indoorEnabled.map {
143
- mapView?.isIndoorEnabled = $0
144
- mapView?.indoorDisplay.delegate = $0 == true ? self : nil
145
- }
146
- customMapStyle.map { mapView?.mapStyle = $0 }
147
- mapType.map { mapView?.mapType = $0 }
148
- userInterfaceStyle.map { mapView?.overrideUserInterfaceStyle = $0 }
149
-
150
- mapZoomConfig.map {
151
- mapView?.setMinZoom(
152
- Float($0.min ?? 2),
153
- maxZoom: Float($0.max ?? 21)
154
- )
155
- }
94
+ private func applyProps() {
95
+ ({ self.uiSettings = self.uiSettings })()
96
+ ({ self.mapPadding = self.mapPadding })()
97
+ ({ self.myLocationEnabled = self.myLocationEnabled })()
98
+ ({ self.buildingEnabled = self.buildingEnabled })()
99
+ ({ self.trafficEnabled = self.trafficEnabled })()
100
+ ({ self.indoorEnabled = self.indoorEnabled })()
101
+ ({ self.customMapStyle = self.customMapStyle })()
102
+ ({ self.mapType = self.mapType })()
103
+ ({ self.userInterfaceStyle = self.userInterfaceStyle })()
104
+ ({ self.mapZoomConfig = self.mapZoomConfig })()
105
+ ({ self.locationConfig = self.locationConfig })()
156
106
 
157
- locationConfig.map {
158
- locationHandler.desiredAccuracy =
159
- $0.ios?.desiredAccuracy?.toCLLocationAccuracy
160
- locationHandler.distanceFilterMeters = $0.ios?.distanceFilterMeters
161
- }
162
107
  if !pendingMarkers.isEmpty {
163
108
  pendingMarkers.forEach { addMarkerInternal(id: $0.id, marker: $0.marker) }
164
109
  pendingMarkers.removeAll()
@@ -348,27 +293,16 @@ GMSIndoorDisplayDelegate {
348
293
  animated: Bool,
349
294
  durationMs: Double
350
295
  ) {
351
- if coordinates.isEmpty {
296
+ guard let firstCoordinates = coordinates.first else {
352
297
  return
353
298
  }
354
299
  var bounds = GMSCoordinateBounds(
355
- coordinate: CLLocationCoordinate2D(
356
- latitude: coordinates[0].latitude,
357
- longitude: coordinates[0].longitude
358
- ),
359
- coordinate: CLLocationCoordinate2D(
360
- latitude: coordinates[0].latitude,
361
- longitude: coordinates[0].longitude
362
- )
300
+ coordinate: firstCoordinates.toCLLocationCoordinate2D(),
301
+ coordinate: firstCoordinates.toCLLocationCoordinate2D()
363
302
  )
364
303
 
365
304
  for coord in coordinates.dropFirst() {
366
- bounds = bounds.includingCoordinate(
367
- CLLocationCoordinate2D(
368
- latitude: coord.latitude,
369
- longitude: coord.longitude
370
- )
371
- )
305
+ bounds = bounds.includingCoordinate(coord.toCLLocationCoordinate2D())
372
306
  }
373
307
 
374
308
  let insets = UIEdgeInsets(
@@ -421,7 +355,7 @@ GMSIndoorDisplayDelegate {
421
355
  ) -> NitroModules.Promise<String?> {
422
356
  let promise = Promise<String?>()
423
357
 
424
- DispatchQueue.main.async {
358
+ onMainAsync {
425
359
  guard let mapView = self.mapView else {
426
360
  promise.resolve(withResult: nil)
427
361
  return
@@ -454,7 +388,6 @@ GMSIndoorDisplayDelegate {
454
388
  return
455
389
  }
456
390
 
457
- // Rückgabe
458
391
  if resultIsFile {
459
392
  let filename =
460
393
  "map_snapshot_\(Int(Date().timeIntervalSince1970)).\(format)"
@@ -679,6 +612,8 @@ GMSIndoorDisplayDelegate {
679
612
  }
680
613
 
681
614
  func deinitInternal() {
615
+ guard !deInitialized else { return }
616
+ deInitialized = true
682
617
  onMain {
683
618
  self.locationHandler.stop()
684
619
  self.markerBuilder.cancelAllIconTasks()
@@ -722,36 +657,14 @@ GMSIndoorDisplayDelegate {
722
657
 
723
658
  func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {
724
659
  onMain {
660
+ self.cameraMoveReasonIsGesture = gesture
725
661
  let visibleRegion = mapView.projection.visibleRegion()
726
662
  let bounds = GMSCoordinateBounds(region: visibleRegion)
727
663
 
728
- let center = CLLocationCoordinate2D(
729
- latitude: (bounds.northEast.latitude + bounds.southWest.latitude) / 2.0,
730
- longitude: (bounds.northEast.longitude + bounds.southWest.longitude)
731
- / 2.0
732
- )
733
-
734
- let latDelta = bounds.northEast.latitude - bounds.southWest.latitude
735
- let lngDelta = bounds.northEast.longitude - bounds.southWest.longitude
664
+ let region = bounds.toRNRegion()
665
+ let camera = mapView.camera.toRNCamera()
736
666
 
737
- let cp = mapView.camera
738
- let region = RNRegion(
739
- center: RNLatLng(center.latitude, center.longitude),
740
- latitudeDelta: latDelta,
741
- longitudeDelta: lngDelta
742
- )
743
- let cam = RNCamera(
744
- center: RNLatLng(
745
- latitude: cp.target.latitude,
746
- longitude: cp.target.longitude
747
- ),
748
- zoom: Double(cp.zoom),
749
- bearing: cp.bearing,
750
- tilt: cp.viewingAngle
751
- )
752
- self.cameraMoveReasonIsGesture = gesture
753
-
754
- self.onCameraChangeStart?(region, cam, gesture)
667
+ self.onCameraChange?(region, camera, gesture)
755
668
  }
756
669
  }
757
670
 
@@ -770,31 +683,10 @@ GMSIndoorDisplayDelegate {
770
683
  let visibleRegion = mapView.projection.visibleRegion()
771
684
  let bounds = GMSCoordinateBounds(region: visibleRegion)
772
685
 
773
- let center = CLLocationCoordinate2D(
774
- latitude: (bounds.northEast.latitude + bounds.southWest.latitude) / 2.0,
775
- longitude: (bounds.northEast.longitude + bounds.southWest.longitude)
776
- / 2.0
777
- )
778
-
779
- let latDelta = bounds.northEast.latitude - bounds.southWest.latitude
780
- let lngDelta = bounds.northEast.longitude - bounds.southWest.longitude
686
+ let region = bounds.toRNRegion()
687
+ let camera = mapView.camera.toRNCamera()
781
688
 
782
- let cp = mapView.camera
783
- let region = RNRegion(
784
- center: RNLatLng(center.latitude, center.longitude),
785
- latitudeDelta: latDelta,
786
- longitudeDelta: lngDelta
787
- )
788
- let cam = RNCamera(
789
- center: RNLatLng(
790
- latitude: cp.target.latitude,
791
- longitude: cp.target.longitude
792
- ),
793
- zoom: Double(cp.zoom),
794
- bearing: cp.bearing,
795
- tilt: cp.viewingAngle
796
- )
797
- self.onCameraChange?(region, cam, self.cameraMoveReasonIsGesture)
689
+ self.onCameraChange?(region, camera, self.cameraMoveReasonIsGesture)
798
690
  }
799
691
  }
800
692
 
@@ -803,31 +695,10 @@ GMSIndoorDisplayDelegate {
803
695
  let visibleRegion = mapView.projection.visibleRegion()
804
696
  let bounds = GMSCoordinateBounds(region: visibleRegion)
805
697
 
806
- let center = CLLocationCoordinate2D(
807
- latitude: (bounds.northEast.latitude + bounds.southWest.latitude) / 2.0,
808
- longitude: (bounds.northEast.longitude + bounds.southWest.longitude)
809
- / 2.0
810
- )
698
+ let region = bounds.toRNRegion()
699
+ let camera = mapView.camera.toRNCamera()
811
700
 
812
- let latDelta = bounds.northEast.latitude - bounds.southWest.latitude
813
- let lngDelta = bounds.northEast.longitude - bounds.southWest.longitude
814
-
815
- let cp = mapView.camera
816
- let region = RNRegion(
817
- center: RNLatLng(center.latitude, center.longitude),
818
- latitudeDelta: latDelta,
819
- longitudeDelta: lngDelta
820
- )
821
- let cam = RNCamera(
822
- center: RNLatLng(
823
- latitude: cp.target.latitude,
824
- longitude: cp.target.longitude
825
- ),
826
- zoom: Double(cp.zoom),
827
- bearing: cp.bearing,
828
- tilt: cp.viewingAngle
829
- )
830
- self.onCameraChangeComplete?(region, cam, self.cameraMoveReasonIsGesture)
701
+ self.onCameraChange?(region, camera, self.cameraMoveReasonIsGesture)
831
702
  }
832
703
  }
833
704
 
@@ -837,10 +708,7 @@ GMSIndoorDisplayDelegate {
837
708
  ) {
838
709
  onMain {
839
710
  self.onMapPress?(
840
- RNLatLng(
841
- latitude: coordinate.latitude,
842
- longitude: coordinate.longitude
843
- )
711
+ coordinate.toRNLatLng(),
844
712
  )
845
713
  }
846
714
  }
@@ -875,7 +743,7 @@ GMSIndoorDisplayDelegate {
875
743
  onMain {
876
744
  self.onMarkerDragStart?(
877
745
  marker.userData as? String,
878
- RNLatLng(marker.position.latitude, marker.position.longitude)
746
+ marker.position.toRNLatLng()
879
747
  )
880
748
  }
881
749
  }
@@ -884,7 +752,7 @@ GMSIndoorDisplayDelegate {
884
752
  onMain {
885
753
  self.onMarkerDrag?(
886
754
  marker.userData as? String,
887
- RNLatLng(marker.position.latitude, marker.position.longitude)
755
+ marker.position.toRNLatLng()
888
756
  )
889
757
  }
890
758
  }
@@ -893,7 +761,7 @@ GMSIndoorDisplayDelegate {
893
761
  onMain {
894
762
  self.onMarkerDragEnd?(
895
763
  marker.userData as? String,
896
- RNLatLng(marker.position.latitude, marker.position.longitude)
764
+ marker.position.toRNLatLng()
897
765
  )
898
766
  }
899
767
  }
@@ -924,12 +792,3 @@ GMSIndoorDisplayDelegate {
924
792
  }
925
793
  }
926
794
  }
927
-
928
- @inline(__always)
929
- func onMain(_ block: @escaping () -> Void) {
930
- if Thread.isMainThread {
931
- block()
932
- } else {
933
- DispatchQueue.main.async { block() }
934
- }
935
- }
@@ -34,7 +34,7 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
34
34
  }
35
35
 
36
36
  func showLocationDialog() {
37
- DispatchQueue.main.async {
37
+ onMainAsync { [weak self] in
38
38
  guard let vc = Self.topMostViewController() else { return }
39
39
  let title =
40
40
  Bundle.main.object(forInfoDictionaryKey: "LocationNotAvailableTitle")
@@ -61,7 +61,7 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
61
61
  title: openLocationSettingsButton ?? "Open settings",
62
62
  style: .default
63
63
  ) { _ in
64
- self.openLocationSettings()
64
+ self?.openLocationSettings()
65
65
  }
66
66
  )
67
67
  vc.present(alert, animated: true, completion: nil)
@@ -78,7 +78,7 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
78
78
  }
79
79
 
80
80
  func openLocationSettings() {
81
- DispatchQueue.main.async {
81
+ onMainAsync {
82
82
  let openSettings = {
83
83
  if #available(iOS 18.3, *) {
84
84
  guard
@@ -114,18 +114,10 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
114
114
  didFailWithError error: Error
115
115
  ) {
116
116
  let code: RNLocationErrorCode
117
-
118
117
  if let clError = error as? CLError {
119
- switch clError.code {
120
- case .denied:
121
- code = RNLocationErrorCode.permissionDenied
122
- case .locationUnknown, .network:
123
- code = RNLocationErrorCode.positionUnavailable
124
- default:
125
- code = RNLocationErrorCode.internalError
126
- }
118
+ code = clError.code.toRNLocationErrorCode
127
119
  } else {
128
- code = RNLocationErrorCode.internalError
120
+ code = .internalError
129
121
  }
130
122
  onError?(code)
131
123
  }
@@ -3,11 +3,7 @@ import GoogleMaps
3
3
  final class MapCircleBuilder {
4
4
  func build(_ c: RNCircle) -> GMSCircle {
5
5
  let circle = GMSCircle()
6
- circle.position = CLLocationCoordinate2D(
7
- latitude: c.center.latitude,
8
- longitude: c.center.longitude
9
- )
10
-
6
+ circle.position = c.center.toCLLocationCoordinate2D()
11
7
  circle.radius = c.radius
12
8
  c.fillColor.map { circle.fillColor = $0.toUIColor() }
13
9
  c.strokeColor.map { circle.strokeColor = $0.toUIColor() }
@@ -18,18 +14,34 @@ final class MapCircleBuilder {
18
14
  return circle
19
15
  }
20
16
 
21
- func update(_ next: RNCircle, _ c: GMSCircle) {
22
- c.position = CLLocationCoordinate2D(
23
- latitude: next.center.latitude,
24
- longitude: next.center.longitude
25
- )
26
-
27
- c.radius = next.radius
28
- c.fillColor = next.fillColor?.toUIColor() ?? nil
29
- c.strokeColor = next.strokeColor?.toUIColor() ?? .black
30
- c.strokeWidth = CGFloat(next.strokeWidth ?? 1.0)
31
- c.isTappable = next.pressable ?? false
32
- c.zIndex = Int32(next.zIndex ?? 0)
33
- }
17
+ func update(_ prev: RNCircle, _ next: RNCircle, _ c: GMSCircle) {
18
+ if prev.center.latitude != next.center.latitude
19
+ || prev.center.longitude != next.center.longitude {
20
+ c.position = next.center.toCLLocationCoordinate2D()
21
+ }
22
+
23
+ if prev.radius != next.radius {
24
+ c.radius = next.radius ?? 0
25
+ }
26
+
27
+ if prev.fillColor != next.fillColor {
28
+ c.fillColor = next.fillColor?.toUIColor() ?? .clear
29
+ }
34
30
 
31
+ if prev.strokeColor != next.strokeColor {
32
+ c.strokeColor = next.strokeColor?.toUIColor() ?? .black
33
+ }
34
+
35
+ if prev.strokeWidth != next.strokeWidth {
36
+ c.strokeWidth = CGFloat(next.strokeWidth ?? 1.0)
37
+ }
38
+
39
+ if prev.pressable != next.pressable {
40
+ c.isTappable = next.pressable ?? false
41
+ }
42
+
43
+ if prev.zIndex != next.zIndex {
44
+ c.zIndex = Int32(next.zIndex ?? 0)
45
+ }
46
+ }
35
47
  }
@@ -18,3 +18,23 @@ func withCATransaction(
18
18
  body()
19
19
  CATransaction.commit()
20
20
  }
21
+
22
+ @MainActor @inline(__always)
23
+ func onMain(_ block: @escaping @MainActor () -> Void) {
24
+ if Thread.isMainThread {
25
+ block()
26
+ } else {
27
+ Task { @MainActor in block() }
28
+ }
29
+ }
30
+
31
+ @inline(__always)
32
+ func onMainAsync(
33
+ _ block: @MainActor @escaping () async -> Void
34
+ ) {
35
+ if Thread.isMainThread {
36
+ Task { @MainActor in await block() }
37
+ } else {
38
+ Task { @MainActor in await block() }
39
+ }
40
+ }