react-native-google-maps-plus 1.3.0-dev.2 → 1.3.0-dev.4
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 +92 -8
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +0 -1
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +52 -9
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNLatLngBoundsExtension.kt +17 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNSize.kt +7 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNSnapshotFormat.kt +16 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNSnapshotResultType.kt +9 -0
- package/ios/GoogleMapViewImpl.swift +285 -145
- package/ios/RNGoogleMapsPlusView.swift +86 -38
- package/ios/extensions/RNLatLngBounds+Extension.swift +16 -0
- package/ios/extensions/RNSize+Extension.swift +7 -0
- package/ios/extensions/RNSnapshotFormat+Extension.swift +28 -0
- package/ios/extensions/RNSnapshotResultType+Extension.swift +12 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts +6 -3
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +13 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +51 -7
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +5 -2
- package/nitrogen/generated/android/c++/JRNLatLngBounds.hpp +58 -0
- package/nitrogen/generated/android/c++/JRNSize.hpp +57 -0
- package/nitrogen/generated/android/c++/JRNSnapshotFormat.hpp +62 -0
- package/nitrogen/generated/android/c++/JRNSnapshotOptions.hpp +71 -0
- package/nitrogen/generated/android/c++/JRNSnapshotResultType.hpp +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +14 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLatLngBounds.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNSize.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNSnapshotFormat.kt +22 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNSnapshotOptions.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNSnapshotResultType.kt +21 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +57 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +15 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +40 -5
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +7 -0
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +5 -2
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +58 -4
- package/nitrogen/generated/ios/swift/RNLatLngBounds.swift +46 -0
- package/nitrogen/generated/ios/swift/RNSize.swift +46 -0
- package/nitrogen/generated/ios/swift/RNSnapshotFormat.swift +44 -0
- package/nitrogen/generated/ios/swift/RNSnapshotOptions.swift +87 -0
- package/nitrogen/generated/ios/swift/RNSnapshotResultType.swift +40 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +3 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +12 -3
- package/nitrogen/generated/shared/c++/RNLatLngBounds.hpp +72 -0
- package/nitrogen/generated/shared/c++/RNSize.hpp +71 -0
- package/nitrogen/generated/shared/c++/RNSnapshotFormat.hpp +80 -0
- package/nitrogen/generated/shared/c++/RNSnapshotOptions.hpp +87 -0
- package/nitrogen/generated/shared/c++/RNSnapshotResultType.hpp +76 -0
- package/package.json +1 -1
- package/src/RNGoogleMapsPlusView.nitro.ts +15 -2
- package/src/types.ts +24 -2
|
@@ -41,6 +41,7 @@ GMSIndoorDisplayDelegate {
|
|
|
41
41
|
setupAppLifecycleObservers()
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
@MainActor
|
|
44
45
|
private func setupAppLifecycleObservers() {
|
|
45
46
|
NotificationCenter.default.addObserver(
|
|
46
47
|
self,
|
|
@@ -82,6 +83,7 @@ GMSIndoorDisplayDelegate {
|
|
|
82
83
|
mapReady = true
|
|
83
84
|
}
|
|
84
85
|
|
|
86
|
+
@MainActor
|
|
85
87
|
private func initLocationCallbacks() {
|
|
86
88
|
locationHandler.onUpdate = { [weak self] loc in
|
|
87
89
|
guard let self = self else { return }
|
|
@@ -191,10 +193,16 @@ GMSIndoorDisplayDelegate {
|
|
|
191
193
|
}
|
|
192
194
|
}
|
|
193
195
|
|
|
196
|
+
@MainActor
|
|
194
197
|
var currentCamera: GMSCameraPosition? {
|
|
195
198
|
mapView?.camera
|
|
196
199
|
}
|
|
197
200
|
|
|
201
|
+
@MainActor
|
|
202
|
+
var initialProps: RNInitialProps? {
|
|
203
|
+
didSet {}
|
|
204
|
+
}
|
|
205
|
+
|
|
198
206
|
@MainActor
|
|
199
207
|
var uiSettings: RNMapUiSettings? {
|
|
200
208
|
didSet {
|
|
@@ -268,7 +276,8 @@ GMSIndoorDisplayDelegate {
|
|
|
268
276
|
}
|
|
269
277
|
}
|
|
270
278
|
|
|
271
|
-
@MainActor
|
|
279
|
+
@MainActor
|
|
280
|
+
var mapPadding: RNMapPadding? {
|
|
272
281
|
didSet {
|
|
273
282
|
mapView?.padding =
|
|
274
283
|
mapPadding.map {
|
|
@@ -282,13 +291,15 @@ GMSIndoorDisplayDelegate {
|
|
|
282
291
|
}
|
|
283
292
|
}
|
|
284
293
|
|
|
285
|
-
@MainActor
|
|
294
|
+
@MainActor
|
|
295
|
+
var mapType: GMSMapViewType? {
|
|
286
296
|
didSet {
|
|
287
297
|
mapView?.mapType = mapType ?? .normal
|
|
288
298
|
}
|
|
289
299
|
}
|
|
290
300
|
|
|
291
|
-
@MainActor
|
|
301
|
+
@MainActor
|
|
302
|
+
var locationConfig: RNLocationConfig? {
|
|
292
303
|
didSet {
|
|
293
304
|
locationHandler.desiredAccuracy =
|
|
294
305
|
locationConfig?.ios?.desiredAccuracy?.toCLLocationAccuracy
|
|
@@ -315,11 +326,12 @@ GMSIndoorDisplayDelegate {
|
|
|
315
326
|
var onCameraChange: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
316
327
|
var onCameraChangeComplete: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
317
328
|
|
|
318
|
-
|
|
329
|
+
@MainActor
|
|
330
|
+
func setCamera(camera: GMSCameraPosition, animated: Bool, durationMs: Double) {
|
|
319
331
|
if animated {
|
|
320
332
|
withCATransaction(
|
|
321
333
|
disableActions: false,
|
|
322
|
-
duration:
|
|
334
|
+
duration: durationMs / 1000.0
|
|
323
335
|
) {
|
|
324
336
|
mapView?.animate(to: camera)
|
|
325
337
|
}
|
|
@@ -329,11 +341,12 @@ GMSIndoorDisplayDelegate {
|
|
|
329
341
|
}
|
|
330
342
|
}
|
|
331
343
|
|
|
344
|
+
@MainActor
|
|
332
345
|
func setCameraToCoordinates(
|
|
333
346
|
coordinates: [RNLatLng],
|
|
334
347
|
padding: RNMapPadding,
|
|
335
348
|
animated: Bool,
|
|
336
|
-
|
|
349
|
+
durationMs: Double
|
|
337
350
|
) {
|
|
338
351
|
if coordinates.isEmpty {
|
|
339
352
|
return
|
|
@@ -369,7 +382,7 @@ GMSIndoorDisplayDelegate {
|
|
|
369
382
|
if animated {
|
|
370
383
|
withCATransaction(
|
|
371
384
|
disableActions: false,
|
|
372
|
-
duration:
|
|
385
|
+
duration: durationMs / 1000.0
|
|
373
386
|
) {
|
|
374
387
|
mapView?.animate(with: update)
|
|
375
388
|
}
|
|
@@ -378,6 +391,90 @@ GMSIndoorDisplayDelegate {
|
|
|
378
391
|
}
|
|
379
392
|
}
|
|
380
393
|
|
|
394
|
+
@MainActor
|
|
395
|
+
func setCameraBounds(_ bounds: GMSCoordinateBounds?) {
|
|
396
|
+
mapView?.cameraTargetBounds = bounds
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
@MainActor
|
|
400
|
+
func animateToBounds(
|
|
401
|
+
_ bounds: GMSCoordinateBounds,
|
|
402
|
+
padding: Double,
|
|
403
|
+
durationMs: Double,
|
|
404
|
+
lockBounds: Bool
|
|
405
|
+
) {
|
|
406
|
+
if lockBounds {
|
|
407
|
+
mapView?.cameraTargetBounds = bounds
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
let update = GMSCameraUpdate.fit(bounds, withPadding: CGFloat(padding))
|
|
411
|
+
mapView?.animate(with: update)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
@MainActor
|
|
415
|
+
func snapshot(
|
|
416
|
+
size: CGSize?,
|
|
417
|
+
format: String,
|
|
418
|
+
imageFormat: ImageFormat,
|
|
419
|
+
quality: CGFloat,
|
|
420
|
+
resultIsFile: Bool
|
|
421
|
+
) -> NitroModules.Promise<String?> {
|
|
422
|
+
let promise = Promise<String?>()
|
|
423
|
+
|
|
424
|
+
DispatchQueue.main.async {
|
|
425
|
+
guard let mapView = self.mapView else {
|
|
426
|
+
promise.resolve(withResult: nil)
|
|
427
|
+
return
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
let renderer = UIGraphicsImageRenderer(bounds: mapView.bounds)
|
|
431
|
+
let image = renderer.image { ctx in
|
|
432
|
+
mapView.layer.render(in: ctx.cgContext)
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
var finalImage = image
|
|
436
|
+
|
|
437
|
+
size.map {
|
|
438
|
+
UIGraphicsBeginImageContextWithOptions($0, false, 0.0)
|
|
439
|
+
image.draw(in: CGRect(origin: .zero, size: $0))
|
|
440
|
+
finalImage = UIGraphicsGetImageFromCurrentImageContext() ?? image
|
|
441
|
+
UIGraphicsEndImageContext()
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
let data: Data?
|
|
445
|
+
switch imageFormat {
|
|
446
|
+
case .jpeg:
|
|
447
|
+
data = finalImage.jpegData(compressionQuality: quality)
|
|
448
|
+
case .png:
|
|
449
|
+
data = finalImage.pngData()
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
guard let imageData = data else {
|
|
453
|
+
promise.resolve(withResult: nil)
|
|
454
|
+
return
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Rückgabe
|
|
458
|
+
if resultIsFile {
|
|
459
|
+
let filename =
|
|
460
|
+
"map_snapshot_\(Int(Date().timeIntervalSince1970)).\(format)"
|
|
461
|
+
let fileURL = URL(fileURLWithPath: NSTemporaryDirectory())
|
|
462
|
+
.appendingPathComponent(filename)
|
|
463
|
+
do {
|
|
464
|
+
try imageData.write(to: fileURL)
|
|
465
|
+
promise.resolve(withResult: fileURL.path)
|
|
466
|
+
} catch {
|
|
467
|
+
promise.resolve(withResult: nil)
|
|
468
|
+
}
|
|
469
|
+
} else {
|
|
470
|
+
let base64 = imageData.base64EncodedString()
|
|
471
|
+
promise.resolve(withResult: "data:image/\(format);base64,\(base64)")
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
return promise
|
|
476
|
+
}
|
|
477
|
+
|
|
381
478
|
@MainActor
|
|
382
479
|
func addMarker(id: String, marker: GMSMarker) {
|
|
383
480
|
if mapView == nil {
|
|
@@ -537,7 +634,10 @@ GMSIndoorDisplayDelegate {
|
|
|
537
634
|
|
|
538
635
|
@MainActor
|
|
539
636
|
func clearHeatmaps() {
|
|
540
|
-
heatmapsById.values.forEach {
|
|
637
|
+
heatmapsById.values.forEach {
|
|
638
|
+
$0.clearTileCache()
|
|
639
|
+
$0.map = nil
|
|
640
|
+
}
|
|
541
641
|
heatmapsById.removeAll()
|
|
542
642
|
pendingHeatmaps.removeAll()
|
|
543
643
|
}
|
|
@@ -579,16 +679,21 @@ GMSIndoorDisplayDelegate {
|
|
|
579
679
|
}
|
|
580
680
|
|
|
581
681
|
func deinitInternal() {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
682
|
+
onMain {
|
|
683
|
+
self.locationHandler.stop()
|
|
684
|
+
self.markerBuilder.cancelAllIconTasks()
|
|
685
|
+
self.clearMarkers()
|
|
686
|
+
self.clearPolylines()
|
|
687
|
+
self.clearPolygons()
|
|
688
|
+
self.clearCircles()
|
|
689
|
+
self.clearHeatmaps()
|
|
690
|
+
self.clearKmlLayers()
|
|
691
|
+
self.mapView?.clear()
|
|
692
|
+
self.mapView?.indoorDisplay.delegate = nil
|
|
693
|
+
self.mapView?.delegate = nil
|
|
694
|
+
self.mapView = nil
|
|
695
|
+
self.initialized = false
|
|
696
|
+
}
|
|
592
697
|
}
|
|
593
698
|
|
|
594
699
|
@objc private func appDidBecomeActive() {
|
|
@@ -604,9 +709,6 @@ GMSIndoorDisplayDelegate {
|
|
|
604
709
|
override func didMoveToWindow() {
|
|
605
710
|
super.didMoveToWindow()
|
|
606
711
|
if window != nil {
|
|
607
|
-
if mapView != nil && mapReady {
|
|
608
|
-
onMapReady?(true)
|
|
609
|
-
}
|
|
610
712
|
locationHandler.start()
|
|
611
713
|
} else {
|
|
612
714
|
locationHandler.stop()
|
|
@@ -619,177 +721,215 @@ GMSIndoorDisplayDelegate {
|
|
|
619
721
|
}
|
|
620
722
|
|
|
621
723
|
func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
724
|
+
onMain {
|
|
725
|
+
let visibleRegion = mapView.projection.visibleRegion()
|
|
726
|
+
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
727
|
+
|
|
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
|
+
)
|
|
629
733
|
|
|
630
|
-
|
|
631
|
-
|
|
734
|
+
let latDelta = bounds.northEast.latitude - bounds.southWest.latitude
|
|
735
|
+
let lngDelta = bounds.northEast.longitude - bounds.southWest.longitude
|
|
632
736
|
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
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
|
|
649
753
|
|
|
650
|
-
|
|
754
|
+
self.onCameraChangeStart?(region, cam, gesture)
|
|
755
|
+
}
|
|
651
756
|
}
|
|
652
757
|
|
|
653
758
|
func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
759
|
+
onMain {
|
|
760
|
+
if let last = self.lastSubmittedCameraPosition,
|
|
761
|
+
last.target.latitude == position.target.latitude,
|
|
762
|
+
last.target.longitude == position.target.longitude,
|
|
763
|
+
last.zoom == position.zoom,
|
|
764
|
+
last.bearing == position.bearing,
|
|
765
|
+
last.viewingAngle == position.viewingAngle {
|
|
766
|
+
return
|
|
767
|
+
}
|
|
664
768
|
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
)
|
|
769
|
+
self.lastSubmittedCameraPosition = position
|
|
770
|
+
let visibleRegion = mapView.projection.visibleRegion()
|
|
771
|
+
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
669
772
|
|
|
670
|
-
|
|
671
|
-
|
|
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
|
+
)
|
|
672
778
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
779
|
+
let latDelta = bounds.northEast.latitude - bounds.southWest.latitude
|
|
780
|
+
let lngDelta = bounds.northEast.longitude - bounds.southWest.longitude
|
|
781
|
+
|
|
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)
|
|
798
|
+
}
|
|
690
799
|
}
|
|
691
800
|
|
|
692
801
|
func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition) {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
802
|
+
onMain {
|
|
803
|
+
let visibleRegion = mapView.projection.visibleRegion()
|
|
804
|
+
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
805
|
+
|
|
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
|
+
)
|
|
700
811
|
|
|
701
|
-
|
|
702
|
-
|
|
812
|
+
let latDelta = bounds.northEast.latitude - bounds.southWest.latitude
|
|
813
|
+
let lngDelta = bounds.northEast.longitude - bounds.southWest.longitude
|
|
703
814
|
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
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)
|
|
831
|
+
}
|
|
720
832
|
}
|
|
721
833
|
|
|
722
834
|
func mapView(
|
|
723
835
|
_ mapView: GMSMapView,
|
|
724
836
|
didTapAt coordinate: CLLocationCoordinate2D
|
|
725
837
|
) {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
838
|
+
onMain {
|
|
839
|
+
self.onMapPress?(
|
|
840
|
+
RNLatLng(
|
|
841
|
+
latitude: coordinate.latitude,
|
|
842
|
+
longitude: coordinate.longitude
|
|
843
|
+
)
|
|
730
844
|
)
|
|
731
|
-
|
|
845
|
+
}
|
|
732
846
|
}
|
|
733
847
|
|
|
734
848
|
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
|
|
735
|
-
|
|
736
|
-
|
|
849
|
+
onMain {
|
|
850
|
+
mapView.selectedMarker = marker
|
|
851
|
+
self.onMarkerPress?(marker.userData as? String, )
|
|
852
|
+
}
|
|
737
853
|
return true
|
|
738
854
|
}
|
|
739
855
|
|
|
740
856
|
func mapView(_ mapView: GMSMapView, didTap overlay: GMSOverlay) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
857
|
+
onMain {
|
|
858
|
+
switch overlay {
|
|
859
|
+
case let circle as GMSCircle:
|
|
860
|
+
self.onCirclePress?(circle.userData as? String, )
|
|
744
861
|
|
|
745
|
-
|
|
746
|
-
|
|
862
|
+
case let polygon as GMSPolygon:
|
|
863
|
+
self.onPolygonPress?(polygon.userData as? String, )
|
|
747
864
|
|
|
748
|
-
|
|
749
|
-
|
|
865
|
+
case let polyline as GMSPolyline:
|
|
866
|
+
self.onPolylinePress?(polyline.userData as? String, )
|
|
750
867
|
|
|
751
|
-
|
|
752
|
-
|
|
868
|
+
default:
|
|
869
|
+
break
|
|
870
|
+
}
|
|
753
871
|
}
|
|
754
872
|
}
|
|
755
873
|
|
|
756
874
|
func mapView(_ mapView: GMSMapView, didBeginDragging marker: GMSMarker) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
875
|
+
onMain {
|
|
876
|
+
self.onMarkerDragStart?(
|
|
877
|
+
marker.userData as? String,
|
|
878
|
+
RNLatLng(marker.position.latitude, marker.position.longitude)
|
|
879
|
+
)
|
|
880
|
+
}
|
|
761
881
|
}
|
|
762
882
|
|
|
763
883
|
func mapView(_ mapView: GMSMapView, didDrag marker: GMSMarker) {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
884
|
+
onMain {
|
|
885
|
+
self.onMarkerDrag?(
|
|
886
|
+
marker.userData as? String,
|
|
887
|
+
RNLatLng(marker.position.latitude, marker.position.longitude)
|
|
888
|
+
)
|
|
889
|
+
}
|
|
768
890
|
}
|
|
769
891
|
|
|
770
892
|
func mapView(_ mapView: GMSMapView, didEndDragging marker: GMSMarker) {
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
893
|
+
onMain {
|
|
894
|
+
self.onMarkerDragEnd?(
|
|
895
|
+
marker.userData as? String,
|
|
896
|
+
RNLatLng(marker.position.latitude, marker.position.longitude)
|
|
897
|
+
)
|
|
898
|
+
}
|
|
775
899
|
}
|
|
776
900
|
|
|
777
901
|
func didChangeActiveBuilding(_ building: GMSIndoorBuilding?) {
|
|
778
|
-
|
|
779
|
-
|
|
902
|
+
onMain {
|
|
903
|
+
guard let display = self.mapView?.indoorDisplay, let building else {
|
|
904
|
+
return
|
|
905
|
+
}
|
|
906
|
+
self.onIndoorBuildingFocused?(building.toRNIndoorBuilding(from: display))
|
|
907
|
+
}
|
|
780
908
|
}
|
|
781
909
|
|
|
782
910
|
func didChangeActiveLevel(_ level: GMSIndoorLevel?) {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
911
|
+
onMain {
|
|
912
|
+
guard
|
|
913
|
+
let display = self.mapView?.indoorDisplay,
|
|
914
|
+
let building = display.activeBuilding,
|
|
915
|
+
let level,
|
|
916
|
+
let index = building.levels.firstIndex(where: {
|
|
917
|
+
$0.name == level.name && $0.shortName == level.shortName
|
|
918
|
+
})
|
|
919
|
+
else { return }
|
|
920
|
+
|
|
921
|
+
self.onIndoorLevelActivated?(
|
|
922
|
+
level.toRNIndoorLevel(index: index, active: true)
|
|
923
|
+
)
|
|
924
|
+
}
|
|
793
925
|
}
|
|
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
|
+
}
|
|
795
935
|
}
|