react-native-google-maps-plus 1.0.3-dev.1 → 1.1.0-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 (82) hide show
  1. package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +122 -29
  2. package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +44 -44
  3. package/android/src/main/java/com/rngooglemapsplus/{MapCircle.kt → MapCircleBuilder.kt} +2 -12
  4. package/android/src/main/java/com/rngooglemapsplus/{MapMarker.kt → MapMarkerBuilder.kt} +1 -1
  5. package/android/src/main/java/com/rngooglemapsplus/{MapPolygon.kt → MapPolygonBuilder.kt} +2 -18
  6. package/android/src/main/java/com/rngooglemapsplus/{MapPolyline.kt → MapPolylineBuilder.kt.kt} +2 -19
  7. package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +43 -54
  8. package/android/src/main/java/com/rngooglemapsplus/extensions/RNCameraExtension.kt +19 -0
  9. package/android/src/main/java/com/rngooglemapsplus/extensions/RNLocationPriorityExtension.kt +12 -0
  10. package/android/src/main/java/com/rngooglemapsplus/extensions/RNMapCircleExtension.kt +14 -0
  11. package/android/src/main/java/com/rngooglemapsplus/extensions/RNPolygonExtension.kt +20 -0
  12. package/android/src/main/java/com/rngooglemapsplus/extensions/RNPolylineExtension.kt +21 -0
  13. package/android/src/main/java/com/rngooglemapsplus/extensions/RNUserInterfaceExtension.kt +12 -0
  14. package/android/src/main/java/com/rngooglemapsplus/{Color.kt → extensions/StringExtension.kt} +1 -1
  15. package/android/src/main/java/com/rngooglemapsplus/extensions/ThrowableExtension.kt +38 -0
  16. package/ios/GoogleMapViewImpl.swift +165 -22
  17. package/ios/LocationHandler.swift +29 -69
  18. package/ios/MapCircleBuilder.swift +20 -0
  19. package/ios/{MapMarker.swift → MapMarkerBuilder.swift} +1 -25
  20. package/ios/MapPolygonBuilder.swift +20 -0
  21. package/ios/MapPolylineBuilder.swift +24 -0
  22. package/ios/RNGoogleMapsPlusView.swift +63 -115
  23. package/ios/extensions/RNCamera+Extension.swift +22 -0
  24. package/ios/{MapCircle.swift → extensions/RNCircle+Extension.swift} +0 -19
  25. package/ios/extensions/RNIOSLocationAccuracy+Extensions.swift +19 -0
  26. package/ios/extensions/RNMarker+Extension.swift +24 -0
  27. package/ios/{MapPolygon.swift → extensions/RNPolygon+Extension.swift.swift} +0 -19
  28. package/ios/{MapPolyline.swift → extensions/RNPolyline+Extension.swift.swift} +16 -39
  29. package/ios/extensions/RNUserInterface+Extension.swift +16 -0
  30. package/lib/module/types.js +14 -0
  31. package/lib/module/types.js.map +1 -1
  32. package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts +5 -1
  33. package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
  34. package/lib/typescript/src/types.d.ts +39 -1
  35. package/lib/typescript/src/types.d.ts.map +1 -1
  36. package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +60 -0
  37. package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +8 -0
  38. package/nitrogen/generated/android/c++/JRNAndroidLocationConfig.hpp +63 -0
  39. package/nitrogen/generated/android/c++/JRNAndroidLocationPriority.hpp +65 -0
  40. package/nitrogen/generated/android/c++/JRNIOSLocationAccuracy.hpp +65 -0
  41. package/nitrogen/generated/android/c++/JRNIOSLocationConfig.hpp +59 -0
  42. package/nitrogen/generated/android/c++/JRNInitialProps.hpp +4 -4
  43. package/nitrogen/generated/android/c++/JRNLocationConfig.hpp +65 -0
  44. package/nitrogen/generated/android/c++/JRNMapUiSettings.hpp +93 -0
  45. package/nitrogen/generated/android/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +16 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +24 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNAndroidLocationConfig.kt +35 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNAndroidLocationPriority.kt +23 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIOSLocationAccuracy.kt +23 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIOSLocationConfig.kt +32 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNInitialProps.kt +1 -1
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLocationConfig.kt +32 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapUiSettings.kt +59 -0
  54. package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +108 -0
  55. package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +18 -0
  56. package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +46 -0
  57. package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +20 -0
  58. package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +4 -0
  59. package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +82 -0
  60. package/nitrogen/generated/ios/swift/RNAndroidLocationConfig.swift +93 -0
  61. package/nitrogen/generated/ios/swift/RNAndroidLocationPriority.swift +48 -0
  62. package/nitrogen/generated/ios/swift/RNIOSLocationAccuracy.swift +48 -0
  63. package/nitrogen/generated/ios/swift/RNIOSLocationConfig.swift +70 -0
  64. package/nitrogen/generated/ios/swift/RNInitialProps.swift +6 -6
  65. package/nitrogen/generated/ios/swift/RNLocationConfig.swift +84 -0
  66. package/nitrogen/generated/ios/swift/RNMapUiSettings.swift +277 -0
  67. package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +8 -0
  68. package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +14 -0
  69. package/nitrogen/generated/shared/c++/RNAndroidLocationConfig.hpp +77 -0
  70. package/nitrogen/generated/shared/c++/RNAndroidLocationPriority.hpp +64 -0
  71. package/nitrogen/generated/shared/c++/RNIOSLocationAccuracy.hpp +64 -0
  72. package/nitrogen/generated/shared/c++/RNIOSLocationConfig.hpp +73 -0
  73. package/nitrogen/generated/shared/c++/RNInitialProps.hpp +5 -5
  74. package/nitrogen/generated/shared/c++/RNLocationConfig.hpp +76 -0
  75. package/nitrogen/generated/shared/c++/RNMapUiSettings.hpp +107 -0
  76. package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +48 -0
  77. package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +6 -0
  78. package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +4 -0
  79. package/package.json +1 -1
  80. package/src/RNGoogleMapsPlusView.nitro.ts +6 -0
  81. package/src/types.ts +44 -1
  82. /package/ios/{Color.swift → extensions/String+Extensions.swift} +0 -0
@@ -0,0 +1,19 @@
1
+ package com.rngooglemapsplus.extensions
2
+
3
+ import com.google.android.gms.maps.model.CameraPosition
4
+ import com.google.android.gms.maps.model.LatLng
5
+ import com.rngooglemapsplus.RNCamera
6
+
7
+ fun RNCamera.toCameraPosition(): CameraPosition {
8
+ val builder = CameraPosition.builder()
9
+
10
+ center?.let {
11
+ builder.target(LatLng(it.latitude, it.longitude))
12
+ }
13
+
14
+ zoom?.let { builder.zoom(it.toFloat()) }
15
+ bearing?.let { builder.bearing(it.toFloat()) }
16
+ tilt?.let { builder.tilt(it.toFloat()) }
17
+
18
+ return builder.build()
19
+ }
@@ -0,0 +1,12 @@
1
+ package com.rngooglemapsplus.extensions
2
+
3
+ import com.google.android.gms.location.Priority
4
+ import com.rngooglemapsplus.RNAndroidLocationPriority
5
+
6
+ fun RNAndroidLocationPriority.toGooglePriority(): Int =
7
+ when (this) {
8
+ RNAndroidLocationPriority.PRIORITY_HIGH_ACCURACY -> Priority.PRIORITY_HIGH_ACCURACY
9
+ RNAndroidLocationPriority.PRIORITY_BALANCED_POWER_ACCURACY -> Priority.PRIORITY_BALANCED_POWER_ACCURACY
10
+ RNAndroidLocationPriority.PRIORITY_LOW_POWER -> Priority.PRIORITY_LOW_POWER
11
+ RNAndroidLocationPriority.PRIORITY_PASSIVE -> Priority.PRIORITY_PASSIVE
12
+ }
@@ -0,0 +1,14 @@
1
+ package com.rngooglemapsplus.extensions
2
+
3
+ import com.rngooglemapsplus.RNCircle
4
+
5
+ fun RNCircle.circleEquals(b: RNCircle): Boolean {
6
+ if (zIndex != b.zIndex) return false
7
+ if (pressable != b.pressable) return false
8
+ if (center != b.center) return false
9
+ if (radius != b.radius) return false
10
+ if (strokeWidth != b.strokeWidth) return false
11
+ if (strokeColor != b.strokeColor) return false
12
+ if (fillColor != b.fillColor) return false
13
+ return true
14
+ }
@@ -0,0 +1,20 @@
1
+ package com.rngooglemapsplus.extensions
2
+
3
+ import com.rngooglemapsplus.RNPolygon
4
+
5
+ fun RNPolygon.polygonEquals(b: RNPolygon): Boolean {
6
+ if (zIndex != b.zIndex) return false
7
+ if (pressable != b.pressable) return false
8
+ if (strokeWidth != b.strokeWidth) return false
9
+ if (fillColor != b.fillColor) return false
10
+ if (strokeColor != b.strokeColor) return false
11
+ val ac = coordinates
12
+ val bc = b.coordinates
13
+ if (ac.size != bc.size) return false
14
+ for (i in ac.indices) {
15
+ val p = ac[i]
16
+ val q = bc[i]
17
+ if (p.latitude != q.latitude || p.longitude != q.longitude) return false
18
+ }
19
+ return true
20
+ }
@@ -0,0 +1,21 @@
1
+ package com.rngooglemapsplus.extensions
2
+
3
+ import com.rngooglemapsplus.RNPolyline
4
+
5
+ fun RNPolyline.polylineEquals(b: RNPolyline): Boolean {
6
+ if (zIndex != b.zIndex) return false
7
+ if (pressable != b.pressable) return false
8
+ if ((width ?: 0.0) != (b.width ?: 0.0)) return false
9
+ if (lineCap != b.lineCap) return false
10
+ if (lineJoin != b.lineJoin) return false
11
+ if (color != b.color) return false
12
+ val ac = coordinates
13
+ val bc = b.coordinates
14
+ if (ac.size != bc.size) return false
15
+ for (i in ac.indices) {
16
+ val p = ac[i]
17
+ val q = bc[i]
18
+ if (p.latitude != q.latitude || p.longitude != q.longitude) return false
19
+ }
20
+ return true
21
+ }
@@ -0,0 +1,12 @@
1
+ package com.rngooglemapsplus.extensions
2
+
3
+ import com.google.android.gms.maps.model.MapColorScheme
4
+ import com.rngooglemapsplus.RNUserInterfaceStyle
5
+
6
+ fun RNUserInterfaceStyle?.toMapColorScheme(): Int? =
7
+ when (this) {
8
+ RNUserInterfaceStyle.LIGHT -> MapColorScheme.LIGHT
9
+ RNUserInterfaceStyle.DARK -> MapColorScheme.DARK
10
+ RNUserInterfaceStyle.DEFAULT -> MapColorScheme.FOLLOW_SYSTEM
11
+ null -> null
12
+ }
@@ -1,4 +1,4 @@
1
- package com.rngooglemapsplus
1
+ package com.rngooglemapsplus.extensions
2
2
 
3
3
  import android.graphics.Color
4
4
  import androidx.core.graphics.toColorInt
@@ -0,0 +1,38 @@
1
+ package com.rngooglemapsplus.extensions
2
+
3
+ import android.content.Context
4
+ import com.google.android.gms.common.ConnectionResult
5
+ import com.google.android.gms.common.GoogleApiAvailability
6
+ import com.google.android.gms.common.api.ApiException
7
+ import com.google.android.gms.common.api.CommonStatusCodes
8
+ import com.google.android.gms.location.LocationSettingsStatusCodes
9
+ import com.rngooglemapsplus.RNLocationErrorCode
10
+
11
+ fun Throwable.toLocationErrorCode(context: Context): RNLocationErrorCode {
12
+ return when (this) {
13
+ is SecurityException -> RNLocationErrorCode.PERMISSION_DENIED
14
+
15
+ is ApiException ->
16
+ when (statusCode) {
17
+ CommonStatusCodes.NETWORK_ERROR ->
18
+ RNLocationErrorCode.POSITION_UNAVAILABLE
19
+ LocationSettingsStatusCodes.RESOLUTION_REQUIRED,
20
+ LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE,
21
+ ->
22
+ RNLocationErrorCode.SETTINGS_NOT_SATISFIED
23
+ else ->
24
+ RNLocationErrorCode.INTERNAL_ERROR
25
+ }
26
+
27
+ else -> {
28
+ if (message?.contains("GoogleApi", ignoreCase = true) == true) {
29
+ val gms = GoogleApiAvailability.getInstance()
30
+ val status = gms.isGooglePlayServicesAvailable(context)
31
+ if (status != ConnectionResult.SUCCESS) {
32
+ return RNLocationErrorCode.PLAY_SERVICE_NOT_AVAILABLE
33
+ }
34
+ }
35
+ RNLocationErrorCode.INTERNAL_ERROR
36
+ }
37
+ }
38
+ }
@@ -5,7 +5,7 @@ import UIKit
5
5
  final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
6
6
 
7
7
  private let locationHandler: LocationHandler
8
- private let markerOptions: MapMarkerOptions
8
+ private let markerBuilder: MapMarkerBuilder
9
9
  private var mapView: GMSMapView?
10
10
  private var initialized = false
11
11
  private var mapReady = false
@@ -24,26 +24,13 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
24
24
  private var lastSubmittedCameraPosition: GMSCameraPosition?
25
25
  private var lastSubmittedLocation: CLLocation?
26
26
 
27
- var onMapError: ((RNMapErrorCode) -> Void)?
28
- var onMapReady: ((Bool) -> Void)?
29
- var onLocationUpdate: ((RNLocation) -> Void)?
30
- var onLocationError: ((_ error: RNLocationErrorCode) -> Void)?
31
- var onMapPress: ((RNLatLng) -> Void)?
32
- var onMarkerPress: ((String) -> Void)?
33
- var onPolylinePress: ((String) -> Void)?
34
- var onPolygonPress: ((String) -> Void)?
35
- var onCirclePress: ((String) -> Void)?
36
- var onCameraChangeStart: ((RNRegion, RNCamera, Bool) -> Void)?
37
- var onCameraChange: ((RNRegion, RNCamera, Bool) -> Void)?
38
- var onCameraChangeComplete: ((RNRegion, RNCamera, Bool) -> Void)?
39
-
40
27
  init(
41
28
  frame: CGRect = .zero,
42
29
  locationHandler: LocationHandler,
43
- markerOptions: MapMarkerOptions
30
+ markerBuilder: MapMarkerBuilder
44
31
  ) {
45
32
  self.locationHandler = locationHandler
46
- self.markerOptions = markerOptions
33
+ self.markerBuilder = markerBuilder
47
34
  super.init(frame: frame)
48
35
  setupAppLifecycleObservers()
49
36
  }
@@ -132,12 +119,46 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
132
119
  )
133
120
  }
134
121
 
135
- if let style = customMapStyle {
136
- mapView?.mapStyle = style
122
+ if let uiSettings = uiSettings {
123
+ if let allGesturesEnabled = uiSettings.allGesturesEnabled {
124
+ mapView?.settings.setAllGesturesEnabled(allGesturesEnabled)
125
+ }
126
+ if let compassEnabled = uiSettings.compassEnabled {
127
+ mapView?.settings.compassButton = compassEnabled
128
+ }
129
+ if let indoorLevelPickerEnabled = uiSettings.indoorLevelPickerEnabled {
130
+ mapView?.settings.indoorPicker = indoorLevelPickerEnabled
131
+ }
132
+ if let mapToolbarEnabled = uiSettings.mapToolbarEnabled {
133
+ /// not supported
134
+ }
135
+ if let myLocationButtonEnabled = uiSettings.myLocationButtonEnabled {
136
+ mapView?.settings.myLocationButton = myLocationButtonEnabled
137
+ }
138
+ if let rotateEnabled = uiSettings.rotateEnabled {
139
+ mapView?.settings.rotateGestures = rotateEnabled
140
+ }
141
+ if let scrollEnabled = uiSettings.scrollEnabled {
142
+ mapView?.settings.scrollGestures = scrollEnabled
143
+ }
144
+ if let scrollDuringRotateOrZoomEnabled = uiSettings
145
+ .scrollDuringRotateOrZoomEnabled {
146
+ mapView?.settings.allowScrollGesturesDuringRotateOrZoom =
147
+ scrollDuringRotateOrZoomEnabled
148
+ }
149
+ if let tiltEnabled = uiSettings.tiltEnabled {
150
+ mapView?.settings.tiltGestures = tiltEnabled
151
+ }
152
+ if let zoomControlsEnabled = uiSettings.zoomControlsEnabled {
153
+ /// not supported
154
+ }
155
+ if let zoomGesturesEnabled = uiSettings.zoomGesturesEnabled {
156
+ mapView?.settings.zoomGestures = zoomGesturesEnabled
157
+ }
137
158
  }
138
159
 
139
- if let mapType = mapType {
140
- mapView?.mapType = mapType
160
+ if let myLocation = myLocationEnabled {
161
+ mapView?.isMyLocationEnabled = myLocation
141
162
  }
142
163
 
143
164
  if let buildings = buildingEnabled {
@@ -148,6 +169,18 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
148
169
  mapView?.isTrafficEnabled = traffic
149
170
  }
150
171
 
172
+ if let indoor = indoorEnabled {
173
+ mapView?.isIndoorEnabled = indoor
174
+ }
175
+
176
+ if let style = customMapStyle {
177
+ mapView?.mapStyle = style
178
+ }
179
+
180
+ if let mapType = mapType {
181
+ mapView?.mapType = mapType
182
+ }
183
+
151
184
  if let uiStyle = userInterfaceStyle {
152
185
  mapView?.overrideUserInterfaceStyle = uiStyle
153
186
  }
@@ -156,6 +189,13 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
156
189
  mapView?.setMinZoom(Float(minZoom), maxZoom: Float(maxZoom))
157
190
  }
158
191
 
192
+ if let locationConfig = locationConfig {
193
+ locationHandler.desiredAccuracy =
194
+ locationConfig.ios?.desiredAccuracy?.toCLLocationAccuracy
195
+ locationHandler.distanceFilterMeters =
196
+ locationConfig.ios?.distanceFilterMeters
197
+ }
198
+
159
199
  if !pendingMarkers.isEmpty {
160
200
  pendingMarkers.forEach {
161
201
  addMarkerInternal(id: $0.id, marker: $0.marker)
@@ -186,11 +226,80 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
186
226
  mapView?.camera
187
227
  }
188
228
 
229
+ @MainActor
230
+ var uiSettings: RNMapUiSettings? {
231
+ didSet {
232
+ guard let mapView = mapView else { return }
233
+ let settings = mapView.settings
234
+
235
+ if let v = uiSettings {
236
+ if let allGesturesEnabled = v.allGesturesEnabled {
237
+ settings.setAllGesturesEnabled(allGesturesEnabled)
238
+ }
239
+ if let compassEnabled = v.compassEnabled {
240
+ settings.compassButton = compassEnabled
241
+ }
242
+ if let indoorLevelPickerEnabled = v.indoorLevelPickerEnabled {
243
+ settings.indoorPicker = indoorLevelPickerEnabled
244
+ }
245
+ if let mapToolbarEnabled = v.mapToolbarEnabled {
246
+ /// not supported
247
+ }
248
+ if let myLocationButtonEnabled = v.myLocationButtonEnabled {
249
+ settings.myLocationButton = myLocationButtonEnabled
250
+ }
251
+ if let rotateEnabled = v.rotateEnabled {
252
+ settings.rotateGestures = rotateEnabled
253
+ }
254
+ if let scrollEnabled = v.scrollEnabled {
255
+ settings.scrollGestures = scrollEnabled
256
+ }
257
+ if let scrollDuringRotateOrZoomEnabled = v
258
+ .scrollDuringRotateOrZoomEnabled {
259
+ settings.allowScrollGesturesDuringRotateOrZoom =
260
+ scrollDuringRotateOrZoomEnabled
261
+ }
262
+ if let tiltEnabled = v.tiltEnabled {
263
+ settings.tiltGestures = tiltEnabled
264
+ }
265
+ if let zoomControlsEnabled = v.zoomControlsEnabled {
266
+ /// not supported
267
+ }
268
+ if let zoomGesturesEnabled = v.zoomGesturesEnabled {
269
+ settings.zoomGestures = zoomGesturesEnabled
270
+ }
271
+ } else {
272
+ settings.setAllGesturesEnabled(true)
273
+ settings.compassButton = false
274
+ settings.indoorPicker = false
275
+ settings.myLocationButton = false
276
+ settings.rotateGestures = true
277
+ settings.scrollGestures = true
278
+ settings.allowScrollGesturesDuringRotateOrZoom = true
279
+ settings.tiltGestures = true
280
+ settings.zoomGestures = false
281
+ }
282
+ }
283
+ }
284
+
285
+ @MainActor
286
+ var myLocationEnabled: Bool? {
287
+ didSet {
288
+ if let value = myLocationEnabled {
289
+ mapView?.isMyLocationEnabled = value
290
+ } else {
291
+ mapView?.isMyLocationEnabled = false
292
+ }
293
+ }
294
+ }
295
+
189
296
  @MainActor
190
297
  var buildingEnabled: Bool? {
191
298
  didSet {
192
299
  if let value = buildingEnabled {
193
300
  mapView?.isBuildingsEnabled = value
301
+ } else {
302
+ mapView?.isBuildingsEnabled = false
194
303
  }
195
304
  }
196
305
  }
@@ -200,6 +309,19 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
200
309
  didSet {
201
310
  if let value = trafficEnabled {
202
311
  mapView?.isTrafficEnabled = value
312
+ } else {
313
+ mapView?.isTrafficEnabled = false
314
+ }
315
+ }
316
+ }
317
+
318
+ @MainActor
319
+ var indoorEnabled: Bool? {
320
+ didSet {
321
+ if let value = indoorEnabled {
322
+ mapView?.isIndoorEnabled = value
323
+ } else {
324
+ mapView?.isIndoorEnabled = false
203
325
  }
204
326
  }
205
327
  }
@@ -243,7 +365,6 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
243
365
  @MainActor
244
366
  var mapPadding: RNMapPadding? {
245
367
  didSet {
246
- mapPadding
247
368
  if let padding = mapPadding {
248
369
  mapView?.padding = UIEdgeInsets(
249
370
  top: padding.top,
@@ -263,6 +384,28 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
263
384
  }
264
385
  }
265
386
 
387
+ @MainActor var locationConfig: RNLocationConfig? {
388
+ didSet {
389
+ locationHandler.desiredAccuracy =
390
+ locationConfig?.ios?.desiredAccuracy?.toCLLocationAccuracy
391
+ locationHandler.distanceFilterMeters =
392
+ locationConfig?.ios?.distanceFilterMeters
393
+ }
394
+ }
395
+
396
+ var onMapError: ((RNMapErrorCode) -> Void)?
397
+ var onMapReady: ((Bool) -> Void)?
398
+ var onLocationUpdate: ((RNLocation) -> Void)?
399
+ var onLocationError: ((_ error: RNLocationErrorCode) -> Void)?
400
+ var onMapPress: ((RNLatLng) -> Void)?
401
+ var onMarkerPress: ((String) -> Void)?
402
+ var onPolylinePress: ((String) -> Void)?
403
+ var onPolygonPress: ((String) -> Void)?
404
+ var onCirclePress: ((String) -> Void)?
405
+ var onCameraChangeStart: ((RNRegion, RNCamera, Bool) -> Void)?
406
+ var onCameraChange: ((RNRegion, RNCamera, Bool) -> Void)?
407
+ var onCameraChangeComplete: ((RNRegion, RNCamera, Bool) -> Void)?
408
+
266
409
  func setCamera(camera: GMSCameraPosition, animated: Bool, durationMS: Double) {
267
410
  if animated {
268
411
  withCATransaction(
@@ -467,7 +610,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
467
610
  }
468
611
 
469
612
  func deinitInternal() {
470
- markerOptions.cancelAllIconTasks()
613
+ markerBuilder.cancelAllIconTasks()
471
614
  clearMarkers()
472
615
  clearPolylines()
473
616
  clearPolygons()
@@ -2,43 +2,43 @@ import CoreLocation
2
2
  import Foundation
3
3
  import UIKit
4
4
 
5
+ private let kCLLocationAccuracyDefault: CLLocationAccuracy =
6
+ kCLLocationAccuracyBest
7
+ private let kCLDistanceFilterNoneDefault: CLLocationDistance =
8
+ kCLDistanceFilterNone
9
+
5
10
  final class LocationHandler: NSObject, CLLocationManagerDelegate {
6
11
 
7
12
  private let manager = CLLocationManager()
8
- private var priority: Int = Priority.highAccuracy.rawValue
9
- private var interval: TimeInterval = 5.0
10
- private var minUpdateInterval: TimeInterval = 5.0
11
- private var distanceFilterMeters: CLLocationDistance = kCLDistanceFilterNone
13
+
14
+ var desiredAccuracy: CLLocationAccuracy? = kCLLocationAccuracyDefault {
15
+ didSet {
16
+ if let desiredAccuracy = desiredAccuracy {
17
+ manager.desiredAccuracy = desiredAccuracy
18
+ } else {
19
+ manager.desiredAccuracy = kCLLocationAccuracyBest
20
+ }
21
+ }
22
+ }
23
+
24
+ var distanceFilterMeters: CLLocationDistance? = kCLDistanceFilterNoneDefault {
25
+ didSet {
26
+ if let distanceFilterMeters = distanceFilterMeters {
27
+ manager.distanceFilter = distanceFilterMeters
28
+ } else {
29
+ manager.distanceFilter = kCLDistanceFilterNone
30
+ }
31
+ }
32
+ }
12
33
 
13
34
  var onUpdate: ((CLLocation) -> Void)?
14
35
  var onError: ((_ error: RNLocationErrorCode) -> Void)?
15
36
 
16
- private var lastEmit: Date?
17
-
18
37
  override init() {
19
38
  super.init()
20
39
  manager.delegate = self
21
40
  manager.pausesLocationUpdatesAutomatically = true
22
41
  manager.activityType = .other
23
- applyPriority()
24
- }
25
-
26
- func setPriority(_ priority: Int) {
27
- self.priority = priority
28
- applyPriority()
29
- }
30
-
31
- func setInterval(_ seconds: Int) {
32
- self.interval = max(0, TimeInterval(seconds))
33
- }
34
-
35
- func setFastestInterval(_ seconds: Int) {
36
- self.minUpdateInterval = max(0, TimeInterval(seconds))
37
- }
38
-
39
- func setDistanceFilter(_ meters: Double) {
40
- self.distanceFilterMeters = meters >= 0 ? meters : kCLDistanceFilterNone
41
- manager.distanceFilter = distanceFilterMeters
42
42
  }
43
43
 
44
44
  func showLocationDialog() {
@@ -110,36 +110,13 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
110
110
  }
111
111
  }
112
112
 
113
- private func applyPriority() {
114
- guard let p = Priority(rawValue: priority) else {
115
- manager.desiredAccuracy = kCLLocationAccuracyBest
116
- return
117
- }
118
- switch p {
119
- case .highAccuracy:
120
- manager.desiredAccuracy = kCLLocationAccuracyBest
121
- case .balanced:
122
- manager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
123
- case .lowPower:
124
- manager.desiredAccuracy = kCLLocationAccuracyHundredMeters
125
- case .passive:
126
- manager.desiredAccuracy = kCLLocationAccuracyKilometer
127
- }
128
- }
129
-
130
113
  private func startUpdates() {
131
- manager.distanceFilter = distanceFilterMeters
114
+ manager.desiredAccuracy = desiredAccuracy ?? kCLLocationAccuracyDefault
115
+ manager.distanceFilter =
116
+ distanceFilterMeters ?? kCLDistanceFilterNoneDefault
132
117
  manager.startUpdatingLocation()
133
118
  }
134
119
 
135
- private func shouldEmit(now: Date) -> Bool {
136
- if let last = lastEmit {
137
- let delta = now.timeIntervalSince(last)
138
- if delta < minUpdateInterval { return false }
139
- }
140
- return true
141
- }
142
-
143
120
  func locationManager(
144
121
  _ manager: CLLocationManager,
145
122
  didFailWithError error: Error
@@ -166,12 +143,7 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
166
143
  didUpdateLocations locations: [CLLocation]
167
144
  ) {
168
145
  guard let loc = locations.last else { return }
169
- let now = Date()
170
-
171
- if shouldEmit(now: now) {
172
- lastEmit = now
173
- onUpdate?(loc)
174
- }
146
+ onUpdate?(loc)
175
147
  }
176
148
 
177
149
  private static func topMostViewController() -> UIViewController? {
@@ -191,15 +163,3 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
191
163
  }
192
164
 
193
165
  }
194
-
195
- extension LocationHandler {
196
- enum Priority: Int {
197
- case highAccuracy = 100
198
- /// Android: PRIORITY_BALANCED_POWER_ACCURACY
199
- case balanced = 102
200
- /// Android: PRIORITY_LOW_POWER
201
- case lowPower = 104
202
- /// Android: PRIORITY_PASSIVE
203
- case passive = 105
204
- }
205
- }
@@ -0,0 +1,20 @@
1
+ import GoogleMaps
2
+
3
+ final class MapCircleBuilder {
4
+
5
+ func buildCircle(_ c: RNCircle) -> GMSCircle {
6
+ let circle = GMSCircle()
7
+ circle.position = CLLocationCoordinate2D(
8
+ latitude: c.center.latitude,
9
+ longitude: c.center.longitude
10
+ )
11
+ if let r = c.radius { circle.radius = r }
12
+ if let fc = c.fillColor?.toUIColor() { circle.fillColor = fc }
13
+ if let sc = c.strokeColor?.toUIColor() { circle.strokeColor = sc }
14
+ if let sw = c.strokeWidth { circle.strokeWidth = CGFloat(sw) }
15
+ if let pr = c.pressable { circle.isTappable = pr }
16
+ if let zi = c.zIndex { circle.zIndex = Int32(zi) }
17
+
18
+ return circle
19
+ }
20
+ }
@@ -2,7 +2,7 @@ import GoogleMaps
2
2
  import SVGKit
3
3
  import UIKit
4
4
 
5
- final class MapMarkerOptions {
5
+ final class MapMarkerBuilder {
6
6
  private let iconCache = NSCache<NSString, UIImage>()
7
7
  private var tasks: [String: Task<Void, Never>] = [:]
8
8
  private let queue = DispatchQueue(
@@ -174,27 +174,3 @@ final class MapMarkerOptions {
174
174
  }
175
175
 
176
176
  }
177
-
178
- extension RNMarker {
179
- func markerEquals(_ b: RNMarker) -> Bool {
180
- id == b.id && zIndex == b.zIndex
181
- && coordinate.latitude == b.coordinate.latitude
182
- && coordinate.longitude == b.coordinate.longitude
183
- && anchor?.x == b.anchor?.x && anchor?.y == b.anchor?.y
184
- && markerStyleEquals(b)
185
- }
186
-
187
- func markerStyleEquals(_ b: RNMarker) -> Bool {
188
- width == b.width && height == b.height
189
- && iconSvg == b.iconSvg
190
- }
191
-
192
- func styleHash() -> NSString {
193
- var hasher = Hasher()
194
- hasher.combine(width)
195
- hasher.combine(height)
196
- hasher.combine(iconSvg)
197
- return String(hasher.finalize()) as NSString
198
- }
199
-
200
- }
@@ -0,0 +1,20 @@
1
+ import GoogleMaps
2
+
3
+ final class MapPolygonBuilder {
4
+
5
+ func buildPolygon(_ p: RNPolygon) -> GMSPolygon {
6
+ let path = GMSMutablePath()
7
+ p.coordinates.forEach {
8
+ path.add(
9
+ CLLocationCoordinate2D(latitude: $0.latitude, longitude: $0.longitude)
10
+ )
11
+ }
12
+ let pg = GMSPolygon(path: path)
13
+ if let fc = p.fillColor?.toUIColor() { pg.fillColor = fc }
14
+ if let sc = p.strokeColor?.toUIColor() { pg.strokeColor = sc }
15
+ if let sw = p.strokeWidth { pg.strokeWidth = CGFloat(sw) }
16
+ if let pr = p.pressable { pg.isTappable = pr }
17
+ if let zi = p.zIndex { pg.zIndex = Int32(zi) }
18
+ return pg
19
+ }
20
+ }
@@ -0,0 +1,24 @@
1
+ import GoogleMaps
2
+
3
+ final class MapPolylineBuilder {
4
+ func buildPolyline(_ p: RNPolyline) -> GMSPolyline {
5
+ let path = GMSMutablePath()
6
+ p.coordinates.forEach {
7
+ path.add(
8
+ CLLocationCoordinate2D(latitude: $0.latitude, longitude: $0.longitude)
9
+ )
10
+ }
11
+ let pl = GMSPolyline(path: path)
12
+ if let w = p.width { pl.strokeWidth = CGFloat(w) }
13
+ if let c = p.color?.toUIColor() { pl.strokeColor = c }
14
+ if let cap = p.lineCap {
15
+ /// pl.lineCap = mapLineCap(cap)
16
+ }
17
+ if let join = p.lineJoin {
18
+ /// pl.strokeJoin = mapLineJoin(join)
19
+ }
20
+ if let pr = p.pressable { pl.isTappable = pr }
21
+ if let zi = p.zIndex { pl.zIndex = Int32(zi) }
22
+ return pl
23
+ }
24
+ }