react-native-google-maps-plus 1.3.0-dev.1 → 1.3.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.
- package/android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt +107 -5
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +0 -1
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +48 -4
- package/android/src/main/java/com/rngooglemapsplus/extensions/IndoorBuildingExtension.kt +33 -0
- 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 +277 -121
- package/ios/RNGoogleMapsPlusView.swift +78 -27
- package/ios/extensions/IndoorBuilding+Extension.swift +33 -0
- 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 +8 -3
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +25 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/RNGoogleMapsPlusOnLoad.cpp +4 -0
- package/nitrogen/generated/android/c++/JFunc_void_RNIndoorBuilding.hpp +81 -0
- package/nitrogen/generated/android/c++/JFunc_void_RNIndoorLevel.hpp +78 -0
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +99 -7
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +9 -2
- package/nitrogen/generated/android/c++/JRNIndoorBuilding.hpp +86 -0
- package/nitrogen/generated/android/c++/JRNIndoorLevel.hpp +66 -0
- 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/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +8 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/Func_void_RNIndoorBuilding.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/Func_void_RNIndoorLevel.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +42 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIndoorBuilding.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNIndoorLevel.kt +38 -0
- 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.cpp +16 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +148 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +21 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +60 -5
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +10 -0
- package/nitrogen/generated/ios/swift/Func_void_RNIndoorBuilding.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_RNIndoorLevel.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +7 -2
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +122 -4
- package/nitrogen/generated/ios/swift/RNIndoorBuilding.swift +116 -0
- package/nitrogen/generated/ios/swift/RNIndoorLevel.swift +118 -0
- 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 +7 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +22 -3
- package/nitrogen/generated/shared/c++/RNIndoorBuilding.hpp +82 -0
- package/nitrogen/generated/shared/c++/RNIndoorLevel.hpp +80 -0
- 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/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +24 -0
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +4 -0
- package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +2 -0
- package/package.json +1 -1
- package/src/RNGoogleMapsPlusView.nitro.ts +19 -2
- package/src/types.ts +38 -2
|
@@ -3,7 +3,8 @@ import GoogleMaps
|
|
|
3
3
|
import GoogleMapsUtils
|
|
4
4
|
import UIKit
|
|
5
5
|
|
|
6
|
-
final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate
|
|
6
|
+
final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate,
|
|
7
|
+
GMSIndoorDisplayDelegate {
|
|
7
8
|
|
|
8
9
|
private let locationHandler: LocationHandler
|
|
9
10
|
private let markerBuilder: MapMarkerBuilder
|
|
@@ -40,6 +41,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
40
41
|
setupAppLifecycleObservers()
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
@MainActor
|
|
43
45
|
private func setupAppLifecycleObservers() {
|
|
44
46
|
NotificationCenter.default.addObserver(
|
|
45
47
|
self,
|
|
@@ -81,6 +83,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
81
83
|
mapReady = true
|
|
82
84
|
}
|
|
83
85
|
|
|
86
|
+
@MainActor
|
|
84
87
|
private func initLocationCallbacks() {
|
|
85
88
|
locationHandler.onUpdate = { [weak self] loc in
|
|
86
89
|
guard let self = self else { return }
|
|
@@ -136,7 +139,10 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
136
139
|
myLocationEnabled.map { mapView?.isMyLocationEnabled = $0 }
|
|
137
140
|
buildingEnabled.map { mapView?.isBuildingsEnabled = $0 }
|
|
138
141
|
trafficEnabled.map { mapView?.isTrafficEnabled = $0 }
|
|
139
|
-
indoorEnabled.map {
|
|
142
|
+
indoorEnabled.map {
|
|
143
|
+
mapView?.isIndoorEnabled = $0
|
|
144
|
+
mapView?.indoorDisplay.delegate = $0 == true ? self : nil
|
|
145
|
+
}
|
|
140
146
|
customMapStyle.map { mapView?.mapStyle = $0 }
|
|
141
147
|
mapType.map { mapView?.mapType = $0 }
|
|
142
148
|
userInterfaceStyle.map { mapView?.overrideUserInterfaceStyle = $0 }
|
|
@@ -187,6 +193,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
187
193
|
}
|
|
188
194
|
}
|
|
189
195
|
|
|
196
|
+
@MainActor
|
|
190
197
|
var currentCamera: GMSCameraPosition? {
|
|
191
198
|
mapView?.camera
|
|
192
199
|
}
|
|
@@ -236,6 +243,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
236
243
|
var indoorEnabled: Bool? {
|
|
237
244
|
didSet {
|
|
238
245
|
mapView?.isIndoorEnabled = indoorEnabled ?? false
|
|
246
|
+
mapView?.indoorDisplay.delegate = indoorEnabled == true ? self : nil
|
|
239
247
|
}
|
|
240
248
|
}
|
|
241
249
|
|
|
@@ -263,7 +271,8 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
263
271
|
}
|
|
264
272
|
}
|
|
265
273
|
|
|
266
|
-
@MainActor
|
|
274
|
+
@MainActor
|
|
275
|
+
var mapPadding: RNMapPadding? {
|
|
267
276
|
didSet {
|
|
268
277
|
mapView?.padding =
|
|
269
278
|
mapPadding.map {
|
|
@@ -277,13 +286,15 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
277
286
|
}
|
|
278
287
|
}
|
|
279
288
|
|
|
280
|
-
@MainActor
|
|
289
|
+
@MainActor
|
|
290
|
+
var mapType: GMSMapViewType? {
|
|
281
291
|
didSet {
|
|
282
292
|
mapView?.mapType = mapType ?? .normal
|
|
283
293
|
}
|
|
284
294
|
}
|
|
285
295
|
|
|
286
|
-
@MainActor
|
|
296
|
+
@MainActor
|
|
297
|
+
var locationConfig: RNLocationConfig? {
|
|
287
298
|
didSet {
|
|
288
299
|
locationHandler.desiredAccuracy =
|
|
289
300
|
locationConfig?.ios?.desiredAccuracy?.toCLLocationAccuracy
|
|
@@ -304,15 +315,18 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
304
315
|
var onMarkerDragStart: ((String?, RNLatLng) -> Void)?
|
|
305
316
|
var onMarkerDrag: ((String?, RNLatLng) -> Void)?
|
|
306
317
|
var onMarkerDragEnd: ((String?, RNLatLng) -> Void)?
|
|
318
|
+
var onIndoorBuildingFocused: ((RNIndoorBuilding) -> Void)?
|
|
319
|
+
var onIndoorLevelActivated: ((RNIndoorLevel) -> Void)?
|
|
307
320
|
var onCameraChangeStart: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
308
321
|
var onCameraChange: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
309
322
|
var onCameraChangeComplete: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
310
323
|
|
|
311
|
-
|
|
324
|
+
@MainActor
|
|
325
|
+
func setCamera(camera: GMSCameraPosition, animated: Bool, durationMs: Double) {
|
|
312
326
|
if animated {
|
|
313
327
|
withCATransaction(
|
|
314
328
|
disableActions: false,
|
|
315
|
-
duration:
|
|
329
|
+
duration: durationMs / 1000.0
|
|
316
330
|
) {
|
|
317
331
|
mapView?.animate(to: camera)
|
|
318
332
|
}
|
|
@@ -322,11 +336,12 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
322
336
|
}
|
|
323
337
|
}
|
|
324
338
|
|
|
339
|
+
@MainActor
|
|
325
340
|
func setCameraToCoordinates(
|
|
326
341
|
coordinates: [RNLatLng],
|
|
327
342
|
padding: RNMapPadding,
|
|
328
343
|
animated: Bool,
|
|
329
|
-
|
|
344
|
+
durationMs: Double
|
|
330
345
|
) {
|
|
331
346
|
if coordinates.isEmpty {
|
|
332
347
|
return
|
|
@@ -362,7 +377,7 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
362
377
|
if animated {
|
|
363
378
|
withCATransaction(
|
|
364
379
|
disableActions: false,
|
|
365
|
-
duration:
|
|
380
|
+
duration: durationMs / 1000.0
|
|
366
381
|
) {
|
|
367
382
|
mapView?.animate(with: update)
|
|
368
383
|
}
|
|
@@ -371,6 +386,90 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
371
386
|
}
|
|
372
387
|
}
|
|
373
388
|
|
|
389
|
+
@MainActor
|
|
390
|
+
func setCameraBounds(_ bounds: GMSCoordinateBounds?) {
|
|
391
|
+
mapView?.cameraTargetBounds = bounds
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
@MainActor
|
|
395
|
+
func animateToBounds(
|
|
396
|
+
_ bounds: GMSCoordinateBounds,
|
|
397
|
+
padding: Double,
|
|
398
|
+
durationMs: Double,
|
|
399
|
+
lockBounds: Bool
|
|
400
|
+
) {
|
|
401
|
+
if lockBounds {
|
|
402
|
+
mapView?.cameraTargetBounds = bounds
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
let update = GMSCameraUpdate.fit(bounds, withPadding: CGFloat(padding))
|
|
406
|
+
mapView?.animate(with: update)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
@MainActor
|
|
410
|
+
func snapshot(
|
|
411
|
+
size: CGSize?,
|
|
412
|
+
format: String,
|
|
413
|
+
imageFormat: ImageFormat,
|
|
414
|
+
quality: CGFloat,
|
|
415
|
+
resultIsFile: Bool
|
|
416
|
+
) -> NitroModules.Promise<String?> {
|
|
417
|
+
let promise = Promise<String?>()
|
|
418
|
+
|
|
419
|
+
DispatchQueue.main.async {
|
|
420
|
+
guard let mapView = self.mapView else {
|
|
421
|
+
promise.resolve(withResult: nil)
|
|
422
|
+
return
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
let renderer = UIGraphicsImageRenderer(bounds: mapView.bounds)
|
|
426
|
+
let image = renderer.image { ctx in
|
|
427
|
+
mapView.layer.render(in: ctx.cgContext)
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
var finalImage = image
|
|
431
|
+
|
|
432
|
+
size.map {
|
|
433
|
+
UIGraphicsBeginImageContextWithOptions($0, false, 0.0)
|
|
434
|
+
image.draw(in: CGRect(origin: .zero, size: $0))
|
|
435
|
+
finalImage = UIGraphicsGetImageFromCurrentImageContext() ?? image
|
|
436
|
+
UIGraphicsEndImageContext()
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
let data: Data?
|
|
440
|
+
switch imageFormat {
|
|
441
|
+
case .jpeg:
|
|
442
|
+
data = finalImage.jpegData(compressionQuality: quality)
|
|
443
|
+
case .png:
|
|
444
|
+
data = finalImage.pngData()
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
guard let imageData = data else {
|
|
448
|
+
promise.resolve(withResult: nil)
|
|
449
|
+
return
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// Rückgabe
|
|
453
|
+
if resultIsFile {
|
|
454
|
+
let filename =
|
|
455
|
+
"map_snapshot_\(Int(Date().timeIntervalSince1970)).\(format)"
|
|
456
|
+
let fileURL = URL(fileURLWithPath: NSTemporaryDirectory())
|
|
457
|
+
.appendingPathComponent(filename)
|
|
458
|
+
do {
|
|
459
|
+
try imageData.write(to: fileURL)
|
|
460
|
+
promise.resolve(withResult: fileURL.path)
|
|
461
|
+
} catch {
|
|
462
|
+
promise.resolve(withResult: nil)
|
|
463
|
+
}
|
|
464
|
+
} else {
|
|
465
|
+
let base64 = imageData.base64EncodedString()
|
|
466
|
+
promise.resolve(withResult: "data:image/\(format);base64,\(base64)")
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
return promise
|
|
471
|
+
}
|
|
472
|
+
|
|
374
473
|
@MainActor
|
|
375
474
|
func addMarker(id: String, marker: GMSMarker) {
|
|
376
475
|
if mapView == nil {
|
|
@@ -612,158 +711,215 @@ final class GoogleMapsViewImpl: UIView, GMSMapViewDelegate {
|
|
|
612
711
|
}
|
|
613
712
|
|
|
614
713
|
func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
714
|
+
onMain {
|
|
715
|
+
let visibleRegion = mapView.projection.visibleRegion()
|
|
716
|
+
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
717
|
+
|
|
718
|
+
let center = CLLocationCoordinate2D(
|
|
719
|
+
latitude: (bounds.northEast.latitude + bounds.southWest.latitude) / 2.0,
|
|
720
|
+
longitude: (bounds.northEast.longitude + bounds.southWest.longitude)
|
|
721
|
+
/ 2.0
|
|
722
|
+
)
|
|
622
723
|
|
|
623
|
-
|
|
624
|
-
|
|
724
|
+
let latDelta = bounds.northEast.latitude - bounds.southWest.latitude
|
|
725
|
+
let lngDelta = bounds.northEast.longitude - bounds.southWest.longitude
|
|
625
726
|
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
727
|
+
let cp = mapView.camera
|
|
728
|
+
let region = RNRegion(
|
|
729
|
+
center: RNLatLng(center.latitude, center.longitude),
|
|
730
|
+
latitudeDelta: latDelta,
|
|
731
|
+
longitudeDelta: lngDelta
|
|
732
|
+
)
|
|
733
|
+
let cam = RNCamera(
|
|
734
|
+
center: RNLatLng(
|
|
735
|
+
latitude: cp.target.latitude,
|
|
736
|
+
longitude: cp.target.longitude
|
|
737
|
+
),
|
|
738
|
+
zoom: Double(cp.zoom),
|
|
739
|
+
bearing: cp.bearing,
|
|
740
|
+
tilt: cp.viewingAngle
|
|
741
|
+
)
|
|
742
|
+
self.cameraMoveReasonIsGesture = gesture
|
|
642
743
|
|
|
643
|
-
|
|
744
|
+
self.onCameraChangeStart?(region, cam, gesture)
|
|
745
|
+
}
|
|
644
746
|
}
|
|
645
747
|
|
|
646
748
|
func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
749
|
+
onMain {
|
|
750
|
+
if let last = self.lastSubmittedCameraPosition,
|
|
751
|
+
last.target.latitude == position.target.latitude,
|
|
752
|
+
last.target.longitude == position.target.longitude,
|
|
753
|
+
last.zoom == position.zoom,
|
|
754
|
+
last.bearing == position.bearing,
|
|
755
|
+
last.viewingAngle == position.viewingAngle {
|
|
756
|
+
return
|
|
757
|
+
}
|
|
657
758
|
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
)
|
|
759
|
+
self.lastSubmittedCameraPosition = position
|
|
760
|
+
let visibleRegion = mapView.projection.visibleRegion()
|
|
761
|
+
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
662
762
|
|
|
663
|
-
|
|
664
|
-
|
|
763
|
+
let center = CLLocationCoordinate2D(
|
|
764
|
+
latitude: (bounds.northEast.latitude + bounds.southWest.latitude) / 2.0,
|
|
765
|
+
longitude: (bounds.northEast.longitude + bounds.southWest.longitude)
|
|
766
|
+
/ 2.0
|
|
767
|
+
)
|
|
665
768
|
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
769
|
+
let latDelta = bounds.northEast.latitude - bounds.southWest.latitude
|
|
770
|
+
let lngDelta = bounds.northEast.longitude - bounds.southWest.longitude
|
|
771
|
+
|
|
772
|
+
let cp = mapView.camera
|
|
773
|
+
let region = RNRegion(
|
|
774
|
+
center: RNLatLng(center.latitude, center.longitude),
|
|
775
|
+
latitudeDelta: latDelta,
|
|
776
|
+
longitudeDelta: lngDelta
|
|
777
|
+
)
|
|
778
|
+
let cam = RNCamera(
|
|
779
|
+
center: RNLatLng(
|
|
780
|
+
latitude: cp.target.latitude,
|
|
781
|
+
longitude: cp.target.longitude
|
|
782
|
+
),
|
|
783
|
+
zoom: Double(cp.zoom),
|
|
784
|
+
bearing: cp.bearing,
|
|
785
|
+
tilt: cp.viewingAngle
|
|
786
|
+
)
|
|
787
|
+
self.onCameraChange?(region, cam, self.cameraMoveReasonIsGesture)
|
|
788
|
+
}
|
|
683
789
|
}
|
|
684
790
|
|
|
685
791
|
func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition) {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
792
|
+
onMain {
|
|
793
|
+
let visibleRegion = mapView.projection.visibleRegion()
|
|
794
|
+
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
795
|
+
|
|
796
|
+
let center = CLLocationCoordinate2D(
|
|
797
|
+
latitude: (bounds.northEast.latitude + bounds.southWest.latitude) / 2.0,
|
|
798
|
+
longitude: (bounds.northEast.longitude + bounds.southWest.longitude)
|
|
799
|
+
/ 2.0
|
|
800
|
+
)
|
|
693
801
|
|
|
694
|
-
|
|
695
|
-
|
|
802
|
+
let latDelta = bounds.northEast.latitude - bounds.southWest.latitude
|
|
803
|
+
let lngDelta = bounds.northEast.longitude - bounds.southWest.longitude
|
|
696
804
|
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
805
|
+
let cp = mapView.camera
|
|
806
|
+
let region = RNRegion(
|
|
807
|
+
center: RNLatLng(center.latitude, center.longitude),
|
|
808
|
+
latitudeDelta: latDelta,
|
|
809
|
+
longitudeDelta: lngDelta
|
|
810
|
+
)
|
|
811
|
+
let cam = RNCamera(
|
|
812
|
+
center: RNLatLng(
|
|
813
|
+
latitude: cp.target.latitude,
|
|
814
|
+
longitude: cp.target.longitude
|
|
815
|
+
),
|
|
816
|
+
zoom: Double(cp.zoom),
|
|
817
|
+
bearing: cp.bearing,
|
|
818
|
+
tilt: cp.viewingAngle
|
|
819
|
+
)
|
|
820
|
+
self.onCameraChangeComplete?(region, cam, self.cameraMoveReasonIsGesture)
|
|
821
|
+
}
|
|
713
822
|
}
|
|
714
823
|
|
|
715
824
|
func mapView(
|
|
716
825
|
_ mapView: GMSMapView,
|
|
717
826
|
didTapAt coordinate: CLLocationCoordinate2D
|
|
718
827
|
) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
828
|
+
onMain {
|
|
829
|
+
self.onMapPress?(
|
|
830
|
+
RNLatLng(
|
|
831
|
+
latitude: coordinate.latitude,
|
|
832
|
+
longitude: coordinate.longitude
|
|
833
|
+
)
|
|
723
834
|
)
|
|
724
|
-
|
|
835
|
+
}
|
|
725
836
|
}
|
|
726
837
|
|
|
727
838
|
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
|
|
728
|
-
|
|
729
|
-
|
|
839
|
+
onMain {
|
|
840
|
+
mapView.selectedMarker = marker
|
|
841
|
+
self.onMarkerPress?(marker.userData as? String, )
|
|
842
|
+
}
|
|
730
843
|
return true
|
|
731
844
|
}
|
|
732
845
|
|
|
733
846
|
func mapView(_ mapView: GMSMapView, didTap overlay: GMSOverlay) {
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
847
|
+
onMain {
|
|
848
|
+
switch overlay {
|
|
849
|
+
case let circle as GMSCircle:
|
|
850
|
+
self.onCirclePress?(circle.userData as? String, )
|
|
737
851
|
|
|
738
|
-
|
|
739
|
-
|
|
852
|
+
case let polygon as GMSPolygon:
|
|
853
|
+
self.onPolygonPress?(polygon.userData as? String, )
|
|
740
854
|
|
|
741
|
-
|
|
742
|
-
|
|
855
|
+
case let polyline as GMSPolyline:
|
|
856
|
+
self.onPolylinePress?(polyline.userData as? String, )
|
|
743
857
|
|
|
744
|
-
|
|
745
|
-
|
|
858
|
+
default:
|
|
859
|
+
break
|
|
860
|
+
}
|
|
746
861
|
}
|
|
747
862
|
}
|
|
748
863
|
|
|
749
864
|
func mapView(_ mapView: GMSMapView, didBeginDragging marker: GMSMarker) {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
865
|
+
onMain {
|
|
866
|
+
self.onMarkerDragStart?(
|
|
867
|
+
marker.userData as? String,
|
|
868
|
+
RNLatLng(marker.position.latitude, marker.position.longitude)
|
|
869
|
+
)
|
|
870
|
+
}
|
|
754
871
|
}
|
|
755
872
|
|
|
756
873
|
func mapView(_ mapView: GMSMapView, didDrag marker: GMSMarker) {
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
874
|
+
onMain {
|
|
875
|
+
self.onMarkerDrag?(
|
|
876
|
+
marker.userData as? String,
|
|
877
|
+
RNLatLng(marker.position.latitude, marker.position.longitude)
|
|
878
|
+
)
|
|
879
|
+
}
|
|
761
880
|
}
|
|
762
881
|
|
|
763
882
|
func mapView(_ mapView: GMSMapView, didEndDragging marker: GMSMarker) {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
883
|
+
onMain {
|
|
884
|
+
self.onMarkerDragEnd?(
|
|
885
|
+
marker.userData as? String,
|
|
886
|
+
RNLatLng(marker.position.latitude, marker.position.longitude)
|
|
887
|
+
)
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
func didChangeActiveBuilding(_ building: GMSIndoorBuilding?) {
|
|
892
|
+
onMain {
|
|
893
|
+
guard let display = self.mapView?.indoorDisplay, let building else {
|
|
894
|
+
return
|
|
895
|
+
}
|
|
896
|
+
self.onIndoorBuildingFocused?(building.toRNIndoorBuilding(from: display))
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
func didChangeActiveLevel(_ level: GMSIndoorLevel?) {
|
|
901
|
+
onMain {
|
|
902
|
+
guard
|
|
903
|
+
let display = self.mapView?.indoorDisplay,
|
|
904
|
+
let building = display.activeBuilding,
|
|
905
|
+
let level,
|
|
906
|
+
let index = building.levels.firstIndex(where: {
|
|
907
|
+
$0.name == level.name && $0.shortName == level.shortName
|
|
908
|
+
})
|
|
909
|
+
else { return }
|
|
910
|
+
|
|
911
|
+
self.onIndoorLevelActivated?(
|
|
912
|
+
level.toRNIndoorLevel(index: index, active: true)
|
|
913
|
+
)
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
@inline(__always)
|
|
919
|
+
func onMain(_ block: @escaping () -> Void) {
|
|
920
|
+
if Thread.isMainThread {
|
|
921
|
+
block()
|
|
922
|
+
} else {
|
|
923
|
+
DispatchQueue.main.async { block() }
|
|
768
924
|
}
|
|
769
925
|
}
|