react-native-google-maps-plus 1.1.0-dev.1 → 1.1.0-dev.3

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 (67) hide show
  1. package/RNGoogleMapsPlus.podspec +2 -0
  2. package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +38 -103
  3. package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +3 -3
  4. package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +16 -2
  5. package/android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt +48 -27
  6. package/android/src/main/java/com/rngooglemapsplus/MapPolygonBuilder.kt +18 -1
  7. package/android/src/main/java/com/rngooglemapsplus/MapPolylineBuilder.kt.kt +26 -9
  8. package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +48 -72
  9. package/android/src/main/java/com/rngooglemapsplus/extensions/RNMarkerExtension.kt +17 -0
  10. package/ios/GoogleMapViewImpl.swift +94 -212
  11. package/ios/LocationHandler.swift +2 -10
  12. package/ios/MapCircleBuilder.swift +23 -8
  13. package/ios/MapHelper.swift +6 -4
  14. package/ios/MapMarkerBuilder.swift +55 -48
  15. package/ios/MapPolygonBuilder.swift +25 -7
  16. package/ios/MapPolylineBuilder.swift +27 -11
  17. package/ios/RNGoogleMapsPlusView.swift +9 -15
  18. package/ios/extensions/RNCircle+Extension.swift +0 -13
  19. package/ios/extensions/RNMarker+Extension.swift +6 -5
  20. package/ios/extensions/RNPolygon+Extension.swift.swift +2 -19
  21. package/ios/extensions/RNPolyline+Extension.swift.swift +1 -26
  22. package/lib/module/types.js.map +1 -1
  23. package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts +2 -3
  24. package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
  25. package/lib/typescript/src/types.d.ts +9 -2
  26. package/lib/typescript/src/types.d.ts.map +1 -1
  27. package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +14 -15
  28. package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +2 -4
  29. package/nitrogen/generated/android/c++/JRNCircle.hpp +4 -4
  30. package/nitrogen/generated/android/c++/JRNMapZoomConfig.hpp +57 -0
  31. package/nitrogen/generated/android/c++/JRNMarker.hpp +6 -12
  32. package/nitrogen/generated/android/c++/JRNMarkerSvg.hpp +61 -0
  33. package/nitrogen/generated/android/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +2 -6
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +1 -7
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNCircle.kt +1 -1
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapZoomConfig.kt +32 -0
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarker.kt +1 -7
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarkerSvg.kt +35 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/views/HybridRNGoogleMapsPlusViewManager.kt +1 -1
  40. package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.cpp +13 -13
  41. package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +75 -33
  42. package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +6 -0
  43. package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +11 -12
  44. package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +4 -9
  45. package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +1 -2
  46. package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +46 -94
  47. package/nitrogen/generated/ios/swift/RNCamera.swift +1 -8
  48. package/nitrogen/generated/ios/swift/RNCircle.swift +5 -17
  49. package/nitrogen/generated/ios/swift/RNInitialProps.swift +1 -8
  50. package/nitrogen/generated/ios/swift/RNLocationConfig.swift +2 -16
  51. package/nitrogen/generated/ios/swift/RNMapZoomConfig.swift +70 -0
  52. package/nitrogen/generated/ios/swift/RNMarker.swift +18 -35
  53. package/nitrogen/generated/ios/swift/RNMarkerSvg.swift +57 -0
  54. package/nitrogen/generated/ios/swift/RNPolygon.swift +11 -15
  55. package/nitrogen/generated/ios/swift/RNPolyline.swift +11 -15
  56. package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +2 -4
  57. package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +5 -4
  58. package/nitrogen/generated/shared/c++/RNCircle.hpp +5 -5
  59. package/nitrogen/generated/shared/c++/RNMapZoomConfig.hpp +71 -0
  60. package/nitrogen/generated/shared/c++/RNMarker.hpp +8 -13
  61. package/nitrogen/generated/shared/c++/RNMarkerSvg.hpp +75 -0
  62. package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +7 -19
  63. package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +2 -2
  64. package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +1 -2
  65. package/package.json +13 -13
  66. package/src/RNGoogleMapsPlusView.nitro.ts +2 -2
  67. package/src/types.ts +11 -2
@@ -60,22 +60,16 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
60
60
  initialized = true
61
61
  let options = GMSMapViewOptions()
62
62
  options.frame = bounds
63
- if let mapId = mapId {
64
- options.mapID = GMSMapID(identifier: mapId)
65
- }
66
- if let liteMode = liteMode {
67
- /// not supported
68
- }
69
- if let camera = camera {
70
- options.camera = camera
71
- }
63
+
64
+ mapId.map { options.mapID = GMSMapID(identifier: $0) }
65
+ liteMode.map { _ in /* not supported */ }
66
+ camera.map { options.camera = $0 }
67
+
72
68
  mapView = GMSMapView.init(options: options)
73
69
  mapView?.delegate = self
74
70
  mapView?.autoresizingMask = [.flexibleWidth, .flexibleHeight]
75
71
  mapView?.paddingAdjustmentBehavior = .never
76
- if let mapView = mapView {
77
- addSubview(mapView)
78
- }
72
+ mapView.map { addSubview($0) }
79
73
  initLocationCallbacks()
80
74
  applyPending()
81
75
  onMapReady?(true)
@@ -109,115 +103,73 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
109
103
 
110
104
  @MainActor
111
105
  private func applyPending() {
112
-
113
- if let padding = mapPadding {
106
+ mapPadding.map {
114
107
  mapView?.padding = UIEdgeInsets(
115
- top: padding.top,
116
- left: padding.left,
117
- bottom: padding.bottom,
118
- right: padding.right
108
+ top: $0.top,
109
+ left: $0.left,
110
+ bottom: $0.bottom,
111
+ right: $0.right
119
112
  )
120
113
  }
121
114
 
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
115
+ if let v = uiSettings {
116
+ v.allGesturesEnabled.map { mapView?.settings.setAllGesturesEnabled($0) }
117
+ v.compassEnabled.map { mapView?.settings.compassButton = $0 }
118
+ v.indoorLevelPickerEnabled.map { mapView?.settings.indoorPicker = $0 }
119
+ v.mapToolbarEnabled.map { _ in /* not supported */ }
120
+ v.myLocationButtonEnabled.map { mapView?.settings.myLocationButton = $0 }
121
+ v.rotateEnabled.map { mapView?.settings.rotateGestures = $0 }
122
+ v.scrollEnabled.map { mapView?.settings.scrollGestures = $0 }
123
+ v.scrollDuringRotateOrZoomEnabled.map {
124
+ mapView?.settings.allowScrollGesturesDuringRotateOrZoom = $0
151
125
  }
152
- if let zoomControlsEnabled = uiSettings.zoomControlsEnabled {
153
- /// not supported
154
- }
155
- if let zoomGesturesEnabled = uiSettings.zoomGesturesEnabled {
156
- mapView?.settings.zoomGestures = zoomGesturesEnabled
157
- }
158
- }
159
-
160
- if let myLocation = myLocationEnabled {
161
- mapView?.isMyLocationEnabled = myLocation
162
- }
163
-
164
- if let buildings = buildingEnabled {
165
- mapView?.isBuildingsEnabled = buildings
166
- }
167
-
168
- if let traffic = trafficEnabled {
169
- mapView?.isTrafficEnabled = traffic
170
- }
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
-
184
- if let uiStyle = userInterfaceStyle {
185
- mapView?.overrideUserInterfaceStyle = uiStyle
186
- }
187
-
188
- if let minZoom = minZoomLevel, let maxZoom = maxZoomLevel {
189
- mapView?.setMinZoom(Float(minZoom), maxZoom: Float(maxZoom))
126
+ v.tiltEnabled.map { mapView?.settings.tiltGestures = $0 }
127
+ v.zoomControlsEnabled.map { _ in /* not supported */ }
128
+ v.zoomGesturesEnabled.map { mapView?.settings.zoomGestures = $0 }
129
+ }
130
+
131
+ myLocationEnabled.map { mapView?.isMyLocationEnabled = $0 }
132
+ buildingEnabled.map { mapView?.isBuildingsEnabled = $0 }
133
+ trafficEnabled.map { mapView?.isTrafficEnabled = $0 }
134
+ indoorEnabled.map { mapView?.isIndoorEnabled = $0 }
135
+ customMapStyle.map { mapView?.mapStyle = $0 }
136
+ mapType.map { mapView?.mapType = $0 }
137
+ userInterfaceStyle.map { mapView?.overrideUserInterfaceStyle = $0 }
138
+
139
+ mapZoomConfig.map {
140
+ mapView?.setMinZoom(
141
+ Float($0.min ?? 2),
142
+ maxZoom: Float($0.max ?? 21)
143
+ )
190
144
  }
191
145
 
192
- if let locationConfig = locationConfig {
146
+ locationConfig.map {
193
147
  locationHandler.desiredAccuracy =
194
- locationConfig.ios?.desiredAccuracy?.toCLLocationAccuracy
195
- locationHandler.distanceFilterMeters =
196
- locationConfig.ios?.distanceFilterMeters
148
+ $0.ios?.desiredAccuracy?.toCLLocationAccuracy
149
+ locationHandler.distanceFilterMeters = $0.ios?.distanceFilterMeters
197
150
  }
198
151
 
199
152
  if !pendingMarkers.isEmpty {
200
- pendingMarkers.forEach {
201
- addMarkerInternal(id: $0.id, marker: $0.marker)
202
- }
153
+ pendingMarkers.forEach { addMarkerInternal(id: $0.id, marker: $0.marker) }
203
154
  pendingMarkers.removeAll()
204
155
  }
156
+
205
157
  if !pendingPolylines.isEmpty {
206
158
  pendingPolylines.forEach {
207
159
  addPolylineInternal(id: $0.id, polyline: $0.polyline)
208
160
  }
209
161
  pendingPolylines.removeAll()
210
162
  }
163
+
211
164
  if !pendingPolygons.isEmpty {
212
165
  pendingPolygons.forEach {
213
166
  addPolygonInternal(id: $0.id, polygon: $0.polygon)
214
167
  }
215
168
  pendingPolygons.removeAll()
216
169
  }
170
+
217
171
  if !pendingCircles.isEmpty {
218
- pendingCircles.forEach {
219
- addCircleInternal(id: $0.id, circle: $0.circle)
220
- }
172
+ pendingCircles.forEach { addCircleInternal(id: $0.id, circle: $0.circle) }
221
173
  pendingCircles.removeAll()
222
174
  }
223
175
  }
@@ -229,152 +181,86 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
229
181
  @MainActor
230
182
  var uiSettings: RNMapUiSettings? {
231
183
  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
- }
184
+ mapView?.settings.setAllGesturesEnabled(
185
+ uiSettings?.allGesturesEnabled ?? true
186
+ )
187
+ mapView?.settings.compassButton = uiSettings?.compassEnabled ?? false
188
+ mapView?.settings.indoorPicker =
189
+ uiSettings?.indoorLevelPickerEnabled ?? false
190
+ mapView?.settings.myLocationButton =
191
+ uiSettings?.myLocationButtonEnabled ?? false
192
+ mapView?.settings.rotateGestures = uiSettings?.rotateEnabled ?? true
193
+ mapView?.settings.scrollGestures = uiSettings?.scrollEnabled ?? true
194
+ mapView?.settings.allowScrollGesturesDuringRotateOrZoom =
195
+ uiSettings?.scrollDuringRotateOrZoomEnabled ?? true
196
+ mapView?.settings.tiltGestures = uiSettings?.tiltEnabled ?? true
197
+ mapView?.settings.zoomGestures = uiSettings?.zoomGesturesEnabled ?? false
282
198
  }
283
199
  }
284
200
 
285
201
  @MainActor
286
202
  var myLocationEnabled: Bool? {
287
203
  didSet {
288
- if let value = myLocationEnabled {
289
- mapView?.isMyLocationEnabled = value
290
- } else {
291
- mapView?.isMyLocationEnabled = false
292
- }
204
+ mapView?.isMyLocationEnabled = myLocationEnabled ?? false
293
205
  }
294
206
  }
295
207
 
296
208
  @MainActor
297
209
  var buildingEnabled: Bool? {
298
210
  didSet {
299
- if let value = buildingEnabled {
300
- mapView?.isBuildingsEnabled = value
301
- } else {
302
- mapView?.isBuildingsEnabled = false
303
- }
211
+ mapView?.isBuildingsEnabled = buildingEnabled ?? false
304
212
  }
305
213
  }
306
214
 
307
215
  @MainActor
308
216
  var trafficEnabled: Bool? {
309
217
  didSet {
310
- if let value = trafficEnabled {
311
- mapView?.isTrafficEnabled = value
312
- } else {
313
- mapView?.isTrafficEnabled = false
314
- }
218
+ mapView?.isTrafficEnabled = false
315
219
  }
316
220
  }
317
221
 
318
222
  @MainActor
319
223
  var indoorEnabled: Bool? {
320
224
  didSet {
321
- if let value = indoorEnabled {
322
- mapView?.isIndoorEnabled = value
323
- } else {
324
- mapView?.isIndoorEnabled = false
325
- }
225
+ mapView?.isIndoorEnabled = indoorEnabled ?? false
326
226
  }
327
227
  }
328
228
 
329
229
  @MainActor
330
230
  var customMapStyle: GMSMapStyle? {
331
231
  didSet {
332
- if let style = customMapStyle {
333
- mapView?.mapStyle = style
334
- }
232
+ mapView?.mapStyle = customMapStyle
335
233
  }
336
234
  }
337
235
 
338
236
  @MainActor
339
237
  var userInterfaceStyle: UIUserInterfaceStyle? {
340
238
  didSet {
341
- if let style = userInterfaceStyle {
342
- mapView?.overrideUserInterfaceStyle = style
343
- }
239
+ mapView?.overrideUserInterfaceStyle = userInterfaceStyle ?? .unspecified
344
240
  }
345
241
  }
346
242
 
347
243
  @MainActor
348
- var minZoomLevel: Double? {
244
+ var mapZoomConfig: RNMapZoomConfig? {
349
245
  didSet {
350
- if let min = minZoomLevel, let max = maxZoomLevel {
351
- mapView?.setMinZoom(Float(min), maxZoom: Float(max))
352
- }
353
- }
354
- }
355
-
356
- @MainActor
357
- var maxZoomLevel: Double? {
358
- didSet {
359
- if let max = maxZoomLevel, let min = minZoomLevel {
360
- mapView?.setMinZoom(Float(min), maxZoom: Float(max))
361
- }
246
+ mapView?.setMinZoom(
247
+ Float(mapZoomConfig?.min ?? 2),
248
+ maxZoom: Float(mapZoomConfig?.max ?? 21)
249
+ )
362
250
  }
363
251
  }
364
252
 
365
- @MainActor
366
- var mapPadding: RNMapPadding? {
253
+ @MainActor var mapPadding: RNMapPadding? {
367
254
  didSet {
368
- if let padding = mapPadding {
369
- mapView?.padding = UIEdgeInsets(
370
- top: padding.top,
371
- left: padding.left,
372
- bottom: padding.bottom,
373
- right: padding.right
374
- )
375
- } else {
376
- mapView?.padding = .zero
377
- }
255
+ mapView?.padding =
256
+ mapPadding.map {
257
+ UIEdgeInsets(
258
+ top: $0.top,
259
+ left: $0.left,
260
+ bottom: $0.bottom,
261
+ right: $0.right
262
+ )
263
+ } ?? .zero
378
264
  }
379
265
  }
380
266
 
@@ -475,7 +361,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
475
361
  pendingMarkers.append((id, marker))
476
362
  return
477
363
  }
478
- if let old = markersById.removeValue(forKey: id) { old.map = nil }
364
+ markersById.removeValue(forKey: id).map { $0.map = nil }
479
365
  addMarkerInternal(id: id, marker: marker)
480
366
  }
481
367
 
@@ -488,13 +374,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
488
374
 
489
375
  @MainActor
490
376
  func updateMarker(id: String, block: @escaping (GMSMarker) -> Void) {
491
- guard let m = markersById[id] else { return }
492
- block(m)
377
+ markersById[id].map { block($0) }
493
378
  }
494
379
 
495
380
  @MainActor
496
381
  func removeMarker(id: String) {
497
- if let m = markersById.removeValue(forKey: id) { m.map = nil }
382
+ markersById.removeValue(forKey: id).map { $0.map = nil }
498
383
  }
499
384
 
500
385
  @MainActor
@@ -510,7 +395,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
510
395
  pendingPolylines.append((id, polyline))
511
396
  return
512
397
  }
513
- if let old = polylinesById.removeValue(forKey: id) { old.map = nil }
398
+ polylinesById.removeValue(forKey: id).map { $0.map = nil }
514
399
  addPolylineInternal(id: id, polyline: polyline)
515
400
  }
516
401
 
@@ -523,13 +408,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
523
408
 
524
409
  @MainActor
525
410
  func updatePolyline(id: String, block: @escaping (GMSPolyline) -> Void) {
526
- guard let pl = polylinesById[id] else { return }
527
- block(pl)
411
+ polylinesById[id].map { block($0) }
528
412
  }
529
413
 
530
414
  @MainActor
531
415
  func removePolyline(id: String) {
532
- if let pl = polylinesById.removeValue(forKey: id) { pl.map = nil }
416
+ polylinesById.removeValue(forKey: id).map { $0.map = nil }
533
417
  }
534
418
 
535
419
  @MainActor
@@ -545,7 +429,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
545
429
  pendingPolygons.append((id, polygon))
546
430
  return
547
431
  }
548
- if let old = polygonsById.removeValue(forKey: id) { old.map = nil }
432
+ polygonsById.removeValue(forKey: id).map { $0.map = nil }
549
433
  addPolygonInternal(id: id, polygon: polygon)
550
434
  }
551
435
 
@@ -558,13 +442,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
558
442
 
559
443
  @MainActor
560
444
  func updatePolygon(id: String, block: @escaping (GMSPolygon) -> Void) {
561
- guard let pg = polygonsById[id] else { return }
562
- block(pg)
445
+ polygonsById[id].map { block($0) }
563
446
  }
564
447
 
565
448
  @MainActor
566
449
  func removePolygon(id: String) {
567
- if let pg = polygonsById.removeValue(forKey: id) { pg.map = nil }
450
+ polygonsById.removeValue(forKey: id).map { $0.map = nil }
568
451
  }
569
452
 
570
453
  @MainActor
@@ -580,7 +463,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
580
463
  pendingCircles.append((id, circle))
581
464
  return
582
465
  }
583
- if let old = circlesById.removeValue(forKey: id) { old.map = nil }
466
+ circlesById.removeValue(forKey: id).map { $0.map = nil }
584
467
  addCircleInternal(id: id, circle: circle)
585
468
  }
586
469
 
@@ -593,13 +476,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
593
476
 
594
477
  @MainActor
595
478
  func updateCircle(id: String, block: @escaping (GMSCircle) -> Void) {
596
- guard let circle = circlesById[id] else { return }
597
- block(circle)
479
+ circlesById[id].map { block($0) }
598
480
  }
599
481
 
600
482
  @MainActor
601
483
  func removeCircle(id: String) {
602
- if let circle = circlesById.removeValue(forKey: id) { circle.map = nil }
484
+ circlesById.removeValue(forKey: id).map { $0.map = nil }
603
485
  }
604
486
 
605
487
  @MainActor
@@ -13,21 +13,13 @@ final class LocationHandler: NSObject, CLLocationManagerDelegate {
13
13
 
14
14
  var desiredAccuracy: CLLocationAccuracy? = kCLLocationAccuracyDefault {
15
15
  didSet {
16
- if let desiredAccuracy = desiredAccuracy {
17
- manager.desiredAccuracy = desiredAccuracy
18
- } else {
19
- manager.desiredAccuracy = kCLLocationAccuracyBest
20
- }
16
+ manager.desiredAccuracy = desiredAccuracy ?? kCLLocationAccuracyBest
21
17
  }
22
18
  }
23
19
 
24
20
  var distanceFilterMeters: CLLocationDistance? = kCLDistanceFilterNoneDefault {
25
21
  didSet {
26
- if let distanceFilterMeters = distanceFilterMeters {
27
- manager.distanceFilter = distanceFilterMeters
28
- } else {
29
- manager.distanceFilter = kCLDistanceFilterNone
30
- }
22
+ manager.distanceFilter = distanceFilterMeters ?? kCLDistanceFilterNone
31
23
  }
32
24
  }
33
25
 
@@ -1,20 +1,35 @@
1
1
  import GoogleMaps
2
2
 
3
3
  final class MapCircleBuilder {
4
-
5
- func buildCircle(_ c: RNCircle) -> GMSCircle {
4
+ func build(_ c: RNCircle) -> GMSCircle {
6
5
  let circle = GMSCircle()
7
6
  circle.position = CLLocationCoordinate2D(
8
7
  latitude: c.center.latitude,
9
8
  longitude: c.center.longitude
10
9
  )
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) }
10
+
11
+ circle.radius = c.radius
12
+ c.fillColor.map { circle.fillColor = $0.toUIColor() }
13
+ c.strokeColor.map { circle.strokeColor = $0.toUIColor() }
14
+ c.strokeWidth.map { circle.strokeWidth = CGFloat($0) }
15
+ c.pressable.map { circle.isTappable = $0 }
16
+ c.zIndex.map { circle.zIndex = Int32($0) }
17
17
 
18
18
  return circle
19
19
  }
20
+
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
+ }
34
+
20
35
  }
@@ -9,10 +9,12 @@ func withCATransaction(
9
9
  _ body: () -> Void
10
10
  ) {
11
11
  CATransaction.begin()
12
- if disableActions { CATransaction.setDisableActions(true) }
13
- if let d = duration { CATransaction.setAnimationDuration(d) }
14
- if let tf = timingFunction { CATransaction.setAnimationTimingFunction(tf) }
15
- if let c = completion { CATransaction.setCompletionBlock(c) }
12
+
13
+ CATransaction.setDisableActions(disableActions)
14
+ duration.map { CATransaction.setAnimationDuration($0) }
15
+ timingFunction.map { CATransaction.setAnimationTimingFunction($0) }
16
+ completion.map { CATransaction.setCompletionBlock($0) }
17
+
16
18
  body()
17
19
  CATransaction.commit()
18
20
  }