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.
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +17 -14
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +3 -2
- package/android/src/main/java/com/rngooglemapsplus/extensions/LatLngBoundsExtension.kt +0 -31
- package/ios/GoogleMapViewImpl.swift +320 -260
- package/ios/LocationHandler.swift +2 -4
- package/ios/MapCircleBuilder.swift +28 -28
- package/ios/MapHeatmapBuilder.swift +0 -1
- package/ios/MapHelper.swift +9 -14
- package/ios/MapMarkerBuilder.swift +65 -71
- package/ios/MapPolygonBuilder.swift +32 -32
- package/ios/MapPolylineBuilder.swift +24 -24
- package/ios/MapUrlTileOverlayBuilder.swift +0 -1
- package/ios/RNGoogleMapsPlusView.swift +9 -63
- package/package.json +1 -1
|
@@ -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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
onMain {
|
|
96
|
+
if self.mapViewInitialized { return }
|
|
97
|
+
self.mapViewInitialized = true
|
|
98
|
+
self.googleMapOptions.frame = self.bounds
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
118
|
-
|
|
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
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
232
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
254
|
-
|
|
255
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
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
|
-
|
|
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
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
370
|
-
|
|
371
|
-
|
|
383
|
+
for coordinate in coordinates.dropFirst() {
|
|
384
|
+
bounds = bounds.includingCoordinate(
|
|
385
|
+
coordinate.toCLLocationCoordinate2D()
|
|
386
|
+
)
|
|
387
|
+
}
|
|
372
388
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
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
|
-
|
|
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
|
-
|
|
406
|
-
|
|
407
|
-
|
|
423
|
+
onMain {
|
|
424
|
+
if lockBounds {
|
|
425
|
+
self.mapView?.cameraTargetBounds = bounds
|
|
426
|
+
}
|
|
408
427
|
|
|
409
|
-
|
|
410
|
-
|
|
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
|
-
|
|
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
|
-
|
|
453
|
-
|
|
454
|
-
|
|
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
|
-
|
|
463
|
-
|
|
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
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
mapView.selectedMarker
|
|
472
|
-
|
|
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
|
-
|
|
480
|
-
|
|
481
|
-
|
|
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
|
-
|
|
488
|
-
|
|
489
|
-
|
|
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
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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
|
-
|
|
505
|
-
|
|
506
|
-
|
|
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
|
-
|
|
536
|
+
onMain {
|
|
537
|
+
self.polylinesById[id].map { block($0) }
|
|
538
|
+
}
|
|
512
539
|
}
|
|
513
540
|
|
|
514
|
-
@MainActor
|
|
515
541
|
func removePolyline(id: String) {
|
|
516
|
-
|
|
542
|
+
onMain {
|
|
543
|
+
self.polylinesById.removeValue(forKey: id).map { $0.map = nil }
|
|
544
|
+
}
|
|
517
545
|
}
|
|
518
546
|
|
|
519
|
-
@MainActor
|
|
520
547
|
func clearPolylines() {
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
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
|
-
|
|
529
|
-
|
|
530
|
-
|
|
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
|
-
|
|
539
|
-
|
|
540
|
-
|
|
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
|
-
|
|
575
|
+
onMain {
|
|
576
|
+
self.polygonsById[id].map { block($0) }
|
|
577
|
+
}
|
|
546
578
|
}
|
|
547
579
|
|
|
548
|
-
@MainActor
|
|
549
580
|
func removePolygon(id: String) {
|
|
550
|
-
|
|
581
|
+
onMain {
|
|
582
|
+
self.polygonsById.removeValue(forKey: id).map { $0.map = nil }
|
|
583
|
+
}
|
|
551
584
|
}
|
|
552
585
|
|
|
553
|
-
@MainActor
|
|
554
586
|
func clearPolygons() {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
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
|
-
|
|
563
|
-
|
|
564
|
-
|
|
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
|
-
|
|
573
|
-
|
|
574
|
-
|
|
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
|
-
|
|
614
|
+
onMain {
|
|
615
|
+
self.circlesById[id].map { block($0) }
|
|
616
|
+
}
|
|
580
617
|
}
|
|
581
618
|
|
|
582
|
-
@MainActor
|
|
583
619
|
func removeCircle(id: String) {
|
|
584
|
-
|
|
620
|
+
onMain {
|
|
621
|
+
self.circlesById.removeValue(forKey: id).map { $0.map = nil }
|
|
622
|
+
}
|
|
585
623
|
}
|
|
586
624
|
|
|
587
|
-
@MainActor
|
|
588
625
|
func clearCircles() {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
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
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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
|
-
|
|
607
|
-
|
|
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
|
-
|
|
613
|
-
|
|
614
|
-
|
|
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
|
-
|
|
621
|
-
|
|
622
|
-
|
|
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
|
-
|
|
631
|
-
|
|
632
|
-
|
|
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
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
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
|
-
|
|
700
|
+
onMain {
|
|
701
|
+
self.kmlLayerById.removeValue(forKey: id).map { $0.clear() }
|
|
702
|
+
}
|
|
656
703
|
}
|
|
657
704
|
|
|
658
|
-
@MainActor
|
|
659
705
|
func clearKmlLayers() {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
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
|
-
|
|
668
|
-
|
|
669
|
-
|
|
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
|
-
|
|
681
|
-
|
|
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
|
-
|
|
687
|
-
|
|
688
|
-
|
|
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
|
-
|
|
695
|
-
|
|
696
|
-
|
|
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
|
-
|
|
756
|
-
|
|
757
|
-
let camera = mapView.camera.toRNCamera()
|
|
812
|
+
onMain {
|
|
813
|
+
self.mapViewLoaded = true
|
|
758
814
|
|
|
759
|
-
|
|
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) {
|