react-native-google-maps-plus 1.7.0-dev.1 → 1.7.0-dev.10
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 +457 -451
- package/android/src/main/java/com/rngooglemapsplus/LocationHandler.kt +3 -8
- package/android/src/main/java/com/rngooglemapsplus/MapCircleBuilder.kt +2 -1
- package/android/src/main/java/com/rngooglemapsplus/MapHeatmapBuilder.kt +1 -1
- package/android/src/main/java/com/rngooglemapsplus/MapHelper.kt +22 -0
- package/android/src/main/java/com/rngooglemapsplus/MapMarkerBuilder.kt +103 -2
- package/android/src/main/java/com/rngooglemapsplus/MapPolygonBuilder.kt +2 -1
- package/android/src/main/java/com/rngooglemapsplus/MapPolylineBuilder.kt.kt +2 -1
- package/android/src/main/java/com/rngooglemapsplus/MapUrlTileOverlayBuilder.kt +40 -0
- package/android/src/main/java/com/rngooglemapsplus/RNGoogleMapsPlusView.kt +84 -34
- package/android/src/main/java/com/rngooglemapsplus/extensions/LatLngBoundsExtension.kt +10 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/MapObjectTagExtensions.kt +84 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNLatLngBoundsExtension.kt +2 -8
- package/android/src/main/java/com/rngooglemapsplus/extensions/RNMapTypeExtension.kt +13 -0
- package/android/src/main/java/com/rngooglemapsplus/extensions/VisibleRegionExtension.kt +13 -0
- package/ios/GoogleMapViewImpl.swift +164 -48
- package/ios/MapCircleBuilder.swift +2 -0
- package/ios/MapHeatmapBuilder.swift +2 -1
- package/ios/MapMarkerBuilder.swift +54 -1
- package/ios/MapPolygonBuilder.swift +2 -0
- package/ios/MapPolylineBuilder.swift +2 -0
- package/ios/MapUrlTileOverlayBuilder.swift +24 -0
- package/ios/RNGoogleMapsPlusView.swift +68 -11
- package/ios/extensions/GMSCoordinateBounds+Extension.swift +4 -13
- package/ios/extensions/GMSVisibleRegion+Extension.swift +14 -0
- package/ios/extensions/MapObjectTag+Extension.swift +93 -0
- package/ios/extensions/RNLatLngBounds+Extension.swift +4 -4
- package/ios/extensions/RNMapType+Extension.swift +18 -0
- package/lib/module/types.js.map +1 -1
- package/lib/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +7 -0
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts +18 -9
- package/lib/typescript/src/RNGoogleMapsPlusView.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +18 -5
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/RNGoogleMapsPlusOnLoad.cpp +8 -4
- package/nitrogen/generated/android/c++/JFunc_void_RNRegion_RNCamera.hpp +83 -0
- package/nitrogen/generated/android/c++/JFunc_void_RNRegion_RNCamera_bool.hpp +2 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_RNLatLng.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string_std__string_RNLatLng.hpp +77 -0
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.cpp +237 -83
- package/nitrogen/generated/android/c++/JHybridRNGoogleMapsPlusViewSpec.hpp +32 -16
- package/nitrogen/generated/android/c++/JRNLatLngBounds.hpp +8 -8
- package/nitrogen/generated/android/c++/JRNMapUiSettings.hpp +11 -3
- package/nitrogen/generated/android/c++/JRNMarker.hpp +7 -3
- package/nitrogen/generated/android/c++/JRNRegion.hpp +23 -13
- package/nitrogen/generated/android/c++/JRNUrlTileOverlay.hpp +78 -0
- package/nitrogen/generated/android/c++/views/JHybridRNGoogleMapsPlusViewStateUpdater.cpp +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/Func_void_RNRegion_RNCamera.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/{Func_void_std__optional_std__string_.kt → Func_void_std__string.kt} +12 -12
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/{Func_void_std__optional_std__string__RNLatLng.kt → Func_void_std__string_RNLatLng.kt} +12 -12
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/Func_void_std__string_std__string_RNLatLng.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/HybridRNGoogleMapsPlusViewSpec.kt +122 -24
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNLatLngBounds.kt +4 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMapUiSettings.kt +9 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNMarker.kt +6 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNRegion.kt +11 -5
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/rngooglemapsplus/RNUrlTileOverlay.kt +52 -0
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.cpp +32 -8
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Bridge.hpp +168 -43
- package/nitrogen/generated/ios/RNGoogleMapsPlus-Swift-Cxx-Umbrella.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridRNGoogleMapsPlusViewSpecSwift.hpp +86 -22
- package/nitrogen/generated/ios/c++/views/HybridRNGoogleMapsPlusViewComponent.mm +35 -0
- package/nitrogen/generated/ios/swift/Func_void_RNRegion_RNCamera.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +6 -6
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_RNLatLng.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string_std__string_RNLatLng.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec.swift +17 -8
- package/nitrogen/generated/ios/swift/HybridRNGoogleMapsPlusViewSpec_cxx.swift +340 -138
- package/nitrogen/generated/ios/swift/RNLatLngBounds.swift +8 -8
- package/nitrogen/generated/ios/swift/RNMapUiSettings.swift +61 -1
- package/nitrogen/generated/ios/swift/RNMarker.swift +24 -1
- package/nitrogen/generated/ios/swift/RNRegion.swift +33 -11
- package/nitrogen/generated/ios/swift/RNUrlTileOverlay.swift +133 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.cpp +16 -0
- package/nitrogen/generated/shared/c++/HybridRNGoogleMapsPlusViewSpec.hpp +41 -22
- package/nitrogen/generated/shared/c++/RNLatLngBounds.hpp +9 -9
- package/nitrogen/generated/shared/c++/RNMapUiSettings.hpp +10 -2
- package/nitrogen/generated/shared/c++/RNMarker.hpp +6 -2
- package/nitrogen/generated/shared/c++/RNRegion.hpp +24 -13
- package/nitrogen/generated/shared/c++/RNUrlTileOverlay.hpp +96 -0
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.cpp +100 -16
- package/nitrogen/generated/shared/c++/views/HybridRNGoogleMapsPlusViewComponent.hpp +18 -10
- package/nitrogen/generated/shared/json/RNGoogleMapsPlusViewConfig.json +7 -0
- package/package.json +4 -2
- package/src/RNGoogleMapsPlusView.nitro.ts +20 -8
- package/src/types.ts +19 -5
- package/android/src/main/java/com/rngooglemapsplus/extensions/LatLngBounds.kt +0 -15
- package/nitrogen/generated/android/c++/JFunc_void_std__optional_std__string_.hpp +0 -76
- package/nitrogen/generated/android/c++/JFunc_void_std__optional_std__string__RNLatLng.hpp +0 -78
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string__RNLatLng.swift +0 -54
- /package/android/src/main/java/com/rngooglemapsplus/extensions/{RNSize.kt → RNSizeExtension.kt} +0 -0
- /package/android/src/main/java/com/rngooglemapsplus/extensions/{RNSnapshotFormat.kt → RNSnapshotFormatExtension.kt} +0 -0
- /package/android/src/main/java/com/rngooglemapsplus/extensions/{RNSnapshotResultType.kt → RNSnapshotResultTypeExtension.kt} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.google.android.gms.maps.GoogleMap
|
|
4
|
+
import com.rngooglemapsplus.RNMapType
|
|
5
|
+
|
|
6
|
+
fun RNMapType.toGoogleMapType(): Int =
|
|
7
|
+
when (this) {
|
|
8
|
+
RNMapType.NONE -> GoogleMap.MAP_TYPE_NONE
|
|
9
|
+
RNMapType.NORMAL -> GoogleMap.MAP_TYPE_NORMAL
|
|
10
|
+
RNMapType.HYBRID -> GoogleMap.MAP_TYPE_HYBRID
|
|
11
|
+
RNMapType.SATELLITE -> GoogleMap.MAP_TYPE_SATELLITE
|
|
12
|
+
RNMapType.TERRAIN -> GoogleMap.MAP_TYPE_TERRAIN
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package com.rngooglemapsplus.extensions
|
|
2
|
+
|
|
3
|
+
import com.google.android.gms.maps.model.VisibleRegion
|
|
4
|
+
import com.rngooglemapsplus.RNRegion
|
|
5
|
+
|
|
6
|
+
fun VisibleRegion.toRnRegion(): RNRegion =
|
|
7
|
+
RNRegion(
|
|
8
|
+
nearLeft = nearLeft.toRnLatLng(),
|
|
9
|
+
nearRight = nearRight.toRnLatLng(),
|
|
10
|
+
farLeft = farLeft.toRnLatLng(),
|
|
11
|
+
farRight = farRight.toRnLatLng(),
|
|
12
|
+
latLngBounds = latLngBounds.toRnLatLngBounds(),
|
|
13
|
+
)
|
|
@@ -19,6 +19,7 @@ GMSIndoorDisplayDelegate {
|
|
|
19
19
|
private var pendingCircles: [(id: String, circle: GMSCircle)] = []
|
|
20
20
|
private var pendingHeatmaps: [(id: String, heatmap: GMUHeatmapTileLayer)] = []
|
|
21
21
|
private var pendingKmlLayers: [(id: String, kmlString: String)] = []
|
|
22
|
+
private var pendingUrlTileOverlays: [(id: String, urlTileOverlay: GMSURLTileLayer)] = []
|
|
22
23
|
|
|
23
24
|
private var markersById: [String: GMSMarker] = [:]
|
|
24
25
|
private var polylinesById: [String: GMSPolyline] = [:]
|
|
@@ -26,9 +27,9 @@ GMSIndoorDisplayDelegate {
|
|
|
26
27
|
private var circlesById: [String: GMSCircle] = [:]
|
|
27
28
|
private var heatmapsById: [String: GMUHeatmapTileLayer] = [:]
|
|
28
29
|
private var kmlLayerById: [String: GMUGeometryRenderer] = [:]
|
|
30
|
+
private var urlTileOverlays: [String: GMSURLTileLayer] = [:]
|
|
29
31
|
|
|
30
32
|
private var cameraMoveReasonIsGesture: Bool = false
|
|
31
|
-
private var lastSubmittedCameraPosition: GMSCameraPosition?
|
|
32
33
|
|
|
33
34
|
init(
|
|
34
35
|
frame: CGRect = .zero,
|
|
@@ -135,6 +136,12 @@ GMSIndoorDisplayDelegate {
|
|
|
135
136
|
}
|
|
136
137
|
pendingKmlLayers.removeAll()
|
|
137
138
|
}
|
|
139
|
+
if !pendingUrlTileOverlays.isEmpty {
|
|
140
|
+
pendingUrlTileOverlays.forEach {
|
|
141
|
+
addUrlTileOverlayInternal(id: $0.id, urlTileOverlay: $0.urlTileOverlay)
|
|
142
|
+
}
|
|
143
|
+
pendingUrlTileOverlays.removeAll()
|
|
144
|
+
}
|
|
138
145
|
}
|
|
139
146
|
|
|
140
147
|
@MainActor
|
|
@@ -254,24 +261,49 @@ GMSIndoorDisplayDelegate {
|
|
|
254
261
|
|
|
255
262
|
var onMapError: ((RNMapErrorCode) -> Void)?
|
|
256
263
|
var onMapReady: ((Bool) -> Void)?
|
|
257
|
-
var onMapLoaded: ((
|
|
264
|
+
var onMapLoaded: ((RNRegion, RNCamera) -> Void)?
|
|
258
265
|
var onLocationUpdate: ((RNLocation) -> Void)?
|
|
259
266
|
var onLocationError: ((_ error: RNLocationErrorCode) -> Void)?
|
|
260
267
|
var onMapPress: ((RNLatLng) -> Void)?
|
|
261
268
|
var onMapLongPress: ((RNLatLng) -> Void)?
|
|
262
|
-
var
|
|
263
|
-
var
|
|
264
|
-
var
|
|
265
|
-
var
|
|
266
|
-
var
|
|
267
|
-
var
|
|
268
|
-
var
|
|
269
|
+
var onPoiPress: ((String, String, RNLatLng) -> Void)?
|
|
270
|
+
var onMarkerPress: ((String) -> Void)?
|
|
271
|
+
var onPolylinePress: ((String) -> Void)?
|
|
272
|
+
var onPolygonPress: ((String) -> Void)?
|
|
273
|
+
var onCirclePress: ((String) -> Void)?
|
|
274
|
+
var onMarkerDragStart: ((String, RNLatLng) -> Void)?
|
|
275
|
+
var onMarkerDrag: ((String, RNLatLng) -> Void)?
|
|
276
|
+
var onMarkerDragEnd: ((String, RNLatLng) -> Void)?
|
|
269
277
|
var onIndoorBuildingFocused: ((RNIndoorBuilding) -> Void)?
|
|
270
278
|
var onIndoorLevelActivated: ((RNIndoorLevel) -> Void)?
|
|
279
|
+
var onInfoWindowPress: ((String) -> Void)?
|
|
280
|
+
var onInfoWindowClose: ((String) -> Void)?
|
|
281
|
+
var onInfoWindowLongPress: ((String) -> Void)?
|
|
282
|
+
var onMyLocationPress: ((RNLocation) -> Void)?
|
|
283
|
+
var onMyLocationButtonPress: ((Bool) -> Void)?
|
|
271
284
|
var onCameraChangeStart: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
272
285
|
var onCameraChange: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
273
286
|
var onCameraChangeComplete: ((RNRegion, RNCamera, Bool) -> Void)?
|
|
274
287
|
|
|
288
|
+
@MainActor
|
|
289
|
+
func showMarkerInfoWindow(id: String) {
|
|
290
|
+
onMain {
|
|
291
|
+
guard let marker = self.markersById[id] else { return }
|
|
292
|
+
self.mapView?.selectedMarker = nil
|
|
293
|
+
self.mapView?.selectedMarker = marker
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
@MainActor
|
|
298
|
+
func hideMarkerInfoWindow(id: String) {
|
|
299
|
+
onMain {
|
|
300
|
+
guard let marker = self.markersById[id] else { return }
|
|
301
|
+
if self.mapView?.selectedMarker == marker {
|
|
302
|
+
self.mapView?.selectedMarker = nil
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
275
307
|
@MainActor
|
|
276
308
|
func setCamera(camera: GMSCameraPosition, animated: Bool, durationMs: Double) {
|
|
277
309
|
if animated {
|
|
@@ -421,14 +453,19 @@ GMSIndoorDisplayDelegate {
|
|
|
421
453
|
|
|
422
454
|
@MainActor
|
|
423
455
|
private func addMarkerInternal(id: String, marker: GMSMarker) {
|
|
424
|
-
marker.userData = id
|
|
425
456
|
marker.map = mapView
|
|
426
457
|
markersById[id] = marker
|
|
427
458
|
}
|
|
428
459
|
|
|
429
460
|
@MainActor
|
|
430
461
|
func updateMarker(id: String, block: @escaping (GMSMarker) -> Void) {
|
|
431
|
-
markersById[id].map {
|
|
462
|
+
markersById[id].map {
|
|
463
|
+
block($0)
|
|
464
|
+
if let mapView, mapView.selectedMarker == $0 {
|
|
465
|
+
mapView.selectedMarker = nil
|
|
466
|
+
mapView.selectedMarker = $0
|
|
467
|
+
}
|
|
468
|
+
}
|
|
432
469
|
}
|
|
433
470
|
|
|
434
471
|
@MainActor
|
|
@@ -455,8 +492,8 @@ GMSIndoorDisplayDelegate {
|
|
|
455
492
|
|
|
456
493
|
@MainActor
|
|
457
494
|
private func addPolylineInternal(id: String, polyline: GMSPolyline) {
|
|
495
|
+
polyline.tagData = PolylineTag(id: id)
|
|
458
496
|
polyline.map = mapView
|
|
459
|
-
polyline.userData = id
|
|
460
497
|
polylinesById[id] = polyline
|
|
461
498
|
}
|
|
462
499
|
|
|
@@ -489,8 +526,8 @@ GMSIndoorDisplayDelegate {
|
|
|
489
526
|
|
|
490
527
|
@MainActor
|
|
491
528
|
private func addPolygonInternal(id: String, polygon: GMSPolygon) {
|
|
529
|
+
polygon.tagData = PolygonTag(id: id)
|
|
492
530
|
polygon.map = mapView
|
|
493
|
-
polygon.userData = id
|
|
494
531
|
polygonsById[id] = polygon
|
|
495
532
|
}
|
|
496
533
|
|
|
@@ -523,8 +560,8 @@ GMSIndoorDisplayDelegate {
|
|
|
523
560
|
|
|
524
561
|
@MainActor
|
|
525
562
|
private func addCircleInternal(id: String, circle: GMSCircle) {
|
|
563
|
+
circle.tagData = CircleTag(id: id)
|
|
526
564
|
circle.map = mapView
|
|
527
|
-
circle.userData = id
|
|
528
565
|
circlesById[id] = circle
|
|
529
566
|
}
|
|
530
567
|
|
|
@@ -612,6 +649,36 @@ GMSIndoorDisplayDelegate {
|
|
|
612
649
|
pendingKmlLayers.removeAll()
|
|
613
650
|
}
|
|
614
651
|
|
|
652
|
+
@MainActor
|
|
653
|
+
func addUrlTileOverlay(id: String, urlTileOverlay: GMSURLTileLayer) {
|
|
654
|
+
if mapView == nil {
|
|
655
|
+
pendingUrlTileOverlays.append((id, urlTileOverlay))
|
|
656
|
+
return
|
|
657
|
+
}
|
|
658
|
+
urlTileOverlays.removeValue(forKey: id).map { $0.map = nil }
|
|
659
|
+
addUrlTileOverlayInternal(id: id, urlTileOverlay: urlTileOverlay)
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
@MainActor
|
|
663
|
+
private func addUrlTileOverlayInternal(
|
|
664
|
+
id: String,
|
|
665
|
+
urlTileOverlay: GMSURLTileLayer
|
|
666
|
+
) {
|
|
667
|
+
urlTileOverlay.map = mapView
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
@MainActor
|
|
671
|
+
func removeUrlTileOverlay(id: String) {
|
|
672
|
+
urlTileOverlays.removeValue(forKey: id).map { $0.map = nil }
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
@MainActor
|
|
676
|
+
func clearUrlTileOverlay() {
|
|
677
|
+
urlTileOverlays.values.forEach { $0.map = nil }
|
|
678
|
+
urlTileOverlays.removeAll()
|
|
679
|
+
pendingUrlTileOverlays.removeAll()
|
|
680
|
+
}
|
|
681
|
+
|
|
615
682
|
func deinitInternal() {
|
|
616
683
|
guard !deInitialized else { return }
|
|
617
684
|
deInitialized = true
|
|
@@ -624,6 +691,7 @@ GMSIndoorDisplayDelegate {
|
|
|
624
691
|
self.clearCircles()
|
|
625
692
|
self.clearHeatmaps()
|
|
626
693
|
self.clearKmlLayers()
|
|
694
|
+
self.clearUrlTileOverlay()
|
|
627
695
|
self.mapView?.clear()
|
|
628
696
|
self.mapView?.indoorDisplay.delegate = nil
|
|
629
697
|
self.mapView?.delegate = nil
|
|
@@ -659,53 +727,43 @@ GMSIndoorDisplayDelegate {
|
|
|
659
727
|
func mapViewDidFinishTileRendering(_ mapView: GMSMapView) {
|
|
660
728
|
guard !loaded else { return }
|
|
661
729
|
loaded = true
|
|
662
|
-
|
|
730
|
+
let visibleRegion = mapView.projection.visibleRegion().toRNRegion()
|
|
731
|
+
let camera = mapView.camera.toRNCamera()
|
|
732
|
+
|
|
733
|
+
self.onMapLoaded?(visibleRegion, camera)
|
|
663
734
|
}
|
|
664
735
|
|
|
665
736
|
func mapView(_ mapView: GMSMapView, willMove gesture: Bool) {
|
|
737
|
+
if !loaded { return }
|
|
666
738
|
onMain {
|
|
667
739
|
self.cameraMoveReasonIsGesture = gesture
|
|
668
|
-
let visibleRegion = mapView.projection.visibleRegion()
|
|
669
|
-
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
670
740
|
|
|
671
|
-
let
|
|
741
|
+
let visibleRegion = mapView.projection.visibleRegion().toRNRegion()
|
|
672
742
|
let camera = mapView.camera.toRNCamera()
|
|
673
743
|
|
|
674
|
-
self.onCameraChangeStart?(
|
|
744
|
+
self.onCameraChangeStart?(visibleRegion, camera, gesture)
|
|
675
745
|
}
|
|
676
746
|
}
|
|
677
747
|
|
|
678
748
|
func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
|
|
749
|
+
if !loaded { return }
|
|
679
750
|
onMain {
|
|
680
|
-
|
|
681
|
-
last.target.latitude == position.target.latitude,
|
|
682
|
-
last.target.longitude == position.target.longitude,
|
|
683
|
-
last.zoom == position.zoom,
|
|
684
|
-
last.bearing == position.bearing,
|
|
685
|
-
last.viewingAngle == position.viewingAngle {
|
|
686
|
-
return
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
self.lastSubmittedCameraPosition = position
|
|
690
|
-
let visibleRegion = mapView.projection.visibleRegion()
|
|
691
|
-
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
692
|
-
|
|
693
|
-
let region = bounds.toRNRegion()
|
|
751
|
+
let visibleRegion = mapView.projection.visibleRegion().toRNRegion()
|
|
694
752
|
let camera = mapView.camera.toRNCamera()
|
|
753
|
+
let gesture = self.cameraMoveReasonIsGesture
|
|
695
754
|
|
|
696
|
-
self.onCameraChange?(
|
|
755
|
+
self.onCameraChange?(visibleRegion, camera, gesture)
|
|
697
756
|
}
|
|
698
757
|
}
|
|
699
758
|
|
|
700
759
|
func mapView(_ mapView: GMSMapView, idleAt position: GMSCameraPosition) {
|
|
760
|
+
if !loaded { return }
|
|
701
761
|
onMain {
|
|
702
|
-
let visibleRegion = mapView.projection.visibleRegion()
|
|
703
|
-
let bounds = GMSCoordinateBounds(region: visibleRegion)
|
|
704
|
-
|
|
705
|
-
let region = bounds.toRNRegion()
|
|
762
|
+
let visibleRegion = mapView.projection.visibleRegion().toRNRegion()
|
|
706
763
|
let camera = mapView.camera.toRNCamera()
|
|
764
|
+
let gesture = self.cameraMoveReasonIsGesture
|
|
707
765
|
|
|
708
|
-
self.onCameraChangeComplete?(
|
|
766
|
+
self.onCameraChangeComplete?(visibleRegion, camera, gesture)
|
|
709
767
|
}
|
|
710
768
|
}
|
|
711
769
|
|
|
@@ -731,25 +789,35 @@ GMSIndoorDisplayDelegate {
|
|
|
731
789
|
}
|
|
732
790
|
}
|
|
733
791
|
|
|
792
|
+
func mapView(
|
|
793
|
+
_ mapView: GMSMapView,
|
|
794
|
+
didTapPOIWithPlaceID placeID: String,
|
|
795
|
+
name: String,
|
|
796
|
+
location: CLLocationCoordinate2D
|
|
797
|
+
) {
|
|
798
|
+
onMain {
|
|
799
|
+
self.onPoiPress?(placeID, name, location.toRNLatLng())
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
734
803
|
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
|
|
735
804
|
onMain {
|
|
736
|
-
|
|
737
|
-
self.onMarkerPress?(marker.userData as? String, )
|
|
805
|
+
self.onMarkerPress?(marker.idTag)
|
|
738
806
|
}
|
|
739
|
-
return
|
|
807
|
+
return uiSettings?.consumeOnMarkerPress ?? false
|
|
740
808
|
}
|
|
741
809
|
|
|
742
810
|
func mapView(_ mapView: GMSMapView, didTap overlay: GMSOverlay) {
|
|
743
811
|
onMain {
|
|
744
812
|
switch overlay {
|
|
745
813
|
case let circle as GMSCircle:
|
|
746
|
-
self.onCirclePress?(circle.
|
|
814
|
+
self.onCirclePress?(circle.idTag)
|
|
747
815
|
|
|
748
816
|
case let polygon as GMSPolygon:
|
|
749
|
-
self.onPolygonPress?(polygon.
|
|
817
|
+
self.onPolygonPress?(polygon.idTag)
|
|
750
818
|
|
|
751
819
|
case let polyline as GMSPolyline:
|
|
752
|
-
self.onPolylinePress?(polyline.
|
|
820
|
+
self.onPolylinePress?(polyline.idTag)
|
|
753
821
|
|
|
754
822
|
default:
|
|
755
823
|
break
|
|
@@ -760,7 +828,7 @@ GMSIndoorDisplayDelegate {
|
|
|
760
828
|
func mapView(_ mapView: GMSMapView, didBeginDragging marker: GMSMarker) {
|
|
761
829
|
onMain {
|
|
762
830
|
self.onMarkerDragStart?(
|
|
763
|
-
marker.
|
|
831
|
+
marker.idTag,
|
|
764
832
|
marker.position.toRNLatLng()
|
|
765
833
|
)
|
|
766
834
|
}
|
|
@@ -769,7 +837,7 @@ GMSIndoorDisplayDelegate {
|
|
|
769
837
|
func mapView(_ mapView: GMSMapView, didDrag marker: GMSMarker) {
|
|
770
838
|
onMain {
|
|
771
839
|
self.onMarkerDrag?(
|
|
772
|
-
marker.
|
|
840
|
+
marker.idTag,
|
|
773
841
|
marker.position.toRNLatLng()
|
|
774
842
|
)
|
|
775
843
|
}
|
|
@@ -778,7 +846,7 @@ GMSIndoorDisplayDelegate {
|
|
|
778
846
|
func mapView(_ mapView: GMSMapView, didEndDragging marker: GMSMarker) {
|
|
779
847
|
onMain {
|
|
780
848
|
self.onMarkerDragEnd?(
|
|
781
|
-
marker.
|
|
849
|
+
marker.idTag,
|
|
782
850
|
marker.position.toRNLatLng()
|
|
783
851
|
)
|
|
784
852
|
}
|
|
@@ -809,4 +877,52 @@ GMSIndoorDisplayDelegate {
|
|
|
809
877
|
)
|
|
810
878
|
}
|
|
811
879
|
}
|
|
880
|
+
|
|
881
|
+
func mapView(_ mapView: GMSMapView, didTapInfoWindowOf marker: GMSMarker) {
|
|
882
|
+
onMain {
|
|
883
|
+
self.onInfoWindowPress?(marker.idTag)
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
func mapView(_ mapView: GMSMapView, didCloseInfoWindowOf marker: GMSMarker) {
|
|
888
|
+
onMain {
|
|
889
|
+
self.onInfoWindowClose?(marker.idTag)
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
func mapView(
|
|
894
|
+
_ mapView: GMSMapView,
|
|
895
|
+
didLongPressInfoWindowOf marker: GMSMarker
|
|
896
|
+
) {
|
|
897
|
+
onMain {
|
|
898
|
+
self.onInfoWindowLongPress?(marker.idTag)
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
func mapView(
|
|
903
|
+
_ mapView: GMSMapView,
|
|
904
|
+
didTapMyLocation location: CLLocationCoordinate2D
|
|
905
|
+
) {
|
|
906
|
+
onMain {
|
|
907
|
+
self.mapView?.myLocation.map {
|
|
908
|
+
self.onMyLocationPress?($0.toRnLocation())
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
func didTapMyLocationButton(for mapView: GMSMapView) -> Bool {
|
|
914
|
+
onMain {
|
|
915
|
+
self.onMyLocationButtonPress?(true)
|
|
916
|
+
}
|
|
917
|
+
return uiSettings?.consumeOnMyLocationButtonPress ?? false
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
|
|
921
|
+
return markerBuilder.buildInfoWindow(iconSvg: marker.tagData.iconSvg)
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
func mapView(_ mapView: GMSMapView, markerInfoContents marker: GMSMarker)
|
|
925
|
+
-> UIView? {
|
|
926
|
+
return nil
|
|
927
|
+
}
|
|
812
928
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import GoogleMaps
|
|
2
2
|
|
|
3
3
|
final class MapCircleBuilder {
|
|
4
|
+
@MainActor
|
|
4
5
|
func build(_ c: RNCircle) -> GMSCircle {
|
|
5
6
|
let circle = GMSCircle()
|
|
6
7
|
circle.position = c.center.toCLLocationCoordinate2D()
|
|
@@ -14,6 +15,7 @@ final class MapCircleBuilder {
|
|
|
14
15
|
return circle
|
|
15
16
|
}
|
|
16
17
|
|
|
18
|
+
@MainActor
|
|
17
19
|
func update(_ prev: RNCircle, _ next: RNCircle, _ c: GMSCircle) {
|
|
18
20
|
if prev.center.latitude != next.center.latitude
|
|
19
21
|
|| prev.center.longitude != next.center.longitude {
|
|
@@ -4,6 +4,7 @@ import GoogleMapsUtils
|
|
|
4
4
|
import UIKit
|
|
5
5
|
|
|
6
6
|
final class MapHeatmapBuilder {
|
|
7
|
+
@MainActor
|
|
7
8
|
func build(_ h: RNHeatmap) -> GMUHeatmapTileLayer {
|
|
8
9
|
let heatmap = GMUHeatmapTileLayer()
|
|
9
10
|
heatmap.weightedData = h.weightedData.toWeightedLatLngs()
|
|
@@ -18,7 +19,7 @@ final class MapHeatmapBuilder {
|
|
|
18
19
|
heatmap.gradient = GMUGradient(
|
|
19
20
|
colors: colors,
|
|
20
21
|
startPoints: startPoints,
|
|
21
|
-
colorMapSize:
|
|
22
|
+
colorMapSize: UInt(g.colorMapSize)
|
|
22
23
|
)
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -10,11 +10,11 @@ final class MapMarkerBuilder {
|
|
|
10
10
|
}()
|
|
11
11
|
private var tasks: [String: Task<Void, Never>] = [:]
|
|
12
12
|
|
|
13
|
+
@MainActor
|
|
13
14
|
func build(_ m: RNMarker, icon: UIImage?) -> GMSMarker {
|
|
14
15
|
let marker = GMSMarker(
|
|
15
16
|
position: m.coordinate.toCLLocationCoordinate2D()
|
|
16
17
|
)
|
|
17
|
-
marker.userData = m.id
|
|
18
18
|
marker.tracksViewChanges = true
|
|
19
19
|
marker.icon = icon
|
|
20
20
|
m.title.map { marker.title = $0 }
|
|
@@ -34,6 +34,11 @@ final class MapMarkerBuilder {
|
|
|
34
34
|
}
|
|
35
35
|
m.zIndex.map { marker.zIndex = Int32($0) }
|
|
36
36
|
|
|
37
|
+
marker.tagData = MarkerTag(
|
|
38
|
+
id: m.id,
|
|
39
|
+
iconSvg: m.infoWindowIconSvg
|
|
40
|
+
)
|
|
41
|
+
|
|
37
42
|
onMainAsync { [weak marker] in
|
|
38
43
|
try? await Task.sleep(nanoseconds: 250_000_000)
|
|
39
44
|
marker?.tracksViewChanges = false
|
|
@@ -119,6 +124,12 @@ final class MapMarkerBuilder {
|
|
|
119
124
|
y: next.infoWindowAnchor?.y ?? 0
|
|
120
125
|
)
|
|
121
126
|
}
|
|
127
|
+
|
|
128
|
+
m.tagData = MarkerTag(
|
|
129
|
+
id: next.id,
|
|
130
|
+
iconSvg: next.infoWindowIconSvg
|
|
131
|
+
)
|
|
132
|
+
|
|
122
133
|
}
|
|
123
134
|
}
|
|
124
135
|
|
|
@@ -160,11 +171,13 @@ final class MapMarkerBuilder {
|
|
|
160
171
|
tasks[id] = task
|
|
161
172
|
}
|
|
162
173
|
|
|
174
|
+
@MainActor
|
|
163
175
|
func cancelIconTask(_ id: String) {
|
|
164
176
|
tasks[id]?.cancel()
|
|
165
177
|
tasks.removeValue(forKey: id)
|
|
166
178
|
}
|
|
167
179
|
|
|
180
|
+
@MainActor
|
|
168
181
|
func cancelAllIconTasks() {
|
|
169
182
|
let ids = Array(tasks.keys)
|
|
170
183
|
for id in ids {
|
|
@@ -174,6 +187,46 @@ final class MapMarkerBuilder {
|
|
|
174
187
|
iconCache.removeAllObjects()
|
|
175
188
|
}
|
|
176
189
|
|
|
190
|
+
func buildInfoWindow(iconSvg: RNMarkerSvg?) -> UIImageView? {
|
|
191
|
+
guard let iconSvg = iconSvg else {
|
|
192
|
+
return nil
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
guard let data = iconSvg.svgString.data(using: .utf8),
|
|
196
|
+
let svgImg = SVGKImage(data: data)
|
|
197
|
+
else {
|
|
198
|
+
return nil
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
let size = CGSize(
|
|
202
|
+
width: max(1, CGFloat(iconSvg.width)),
|
|
203
|
+
height: max(1, CGFloat(iconSvg.height))
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
svgImg.size = size
|
|
207
|
+
|
|
208
|
+
guard let base = svgImg.uiImage else {
|
|
209
|
+
return nil
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
let fmt = UIGraphicsImageRendererFormat.default()
|
|
213
|
+
fmt.opaque = false
|
|
214
|
+
fmt.scale = UIScreen.main.scale
|
|
215
|
+
let renderer = UIGraphicsImageRenderer(size: size, format: fmt)
|
|
216
|
+
|
|
217
|
+
let finalImage = renderer.image { _ in
|
|
218
|
+
base.draw(in: CGRect(origin: .zero, size: size))
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
let imageView = UIImageView(image: finalImage)
|
|
222
|
+
imageView.frame = CGRect(origin: .zero, size: size)
|
|
223
|
+
imageView.contentMode = .scaleAspectFit
|
|
224
|
+
imageView.backgroundColor = .clear
|
|
225
|
+
|
|
226
|
+
return imageView
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@MainActor
|
|
177
230
|
private func renderUIImage(_ m: RNMarker, _ scale: CGFloat) async -> UIImage? {
|
|
178
231
|
guard let iconSvg = m.iconSvg,
|
|
179
232
|
let data = iconSvg.svgString.data(using: .utf8)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import GoogleMaps
|
|
2
2
|
|
|
3
3
|
final class MapPolygonBuilder {
|
|
4
|
+
@MainActor
|
|
4
5
|
func build(_ p: RNPolygon) -> GMSPolygon {
|
|
5
6
|
let path = GMSMutablePath()
|
|
6
7
|
p.coordinates.forEach {
|
|
@@ -28,6 +29,7 @@ final class MapPolygonBuilder {
|
|
|
28
29
|
return pg
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
@MainActor
|
|
31
33
|
func update(_ prev: RNPolygon, _ next: RNPolygon, _ pg: GMSPolygon) {
|
|
32
34
|
let coordsChanged =
|
|
33
35
|
prev.coordinates.count != next.coordinates.count
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import GoogleMaps
|
|
2
2
|
|
|
3
3
|
final class MapPolylineBuilder {
|
|
4
|
+
@MainActor
|
|
4
5
|
func build(_ p: RNPolyline) -> GMSPolyline {
|
|
5
6
|
let path = GMSMutablePath()
|
|
6
7
|
p.coordinates.forEach {
|
|
@@ -22,6 +23,7 @@ final class MapPolylineBuilder {
|
|
|
22
23
|
return pl
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
@MainActor
|
|
25
27
|
func update(_ prev: RNPolyline, _ next: RNPolyline, _ pl: GMSPolyline) {
|
|
26
28
|
let coordsChanged =
|
|
27
29
|
prev.coordinates.count != next.coordinates.count
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import GoogleMaps
|
|
2
|
+
|
|
3
|
+
class MapUrlTileOverlayBuilder {
|
|
4
|
+
@MainActor
|
|
5
|
+
func build(_ t: RNUrlTileOverlay) -> GMSURLTileLayer {
|
|
6
|
+
|
|
7
|
+
let constructor: GMSTileURLConstructor = { (x: UInt, y: UInt, zoom: UInt) in
|
|
8
|
+
let urlString = t.url
|
|
9
|
+
.replacingOccurrences(of: "{x}", with: "\(x)")
|
|
10
|
+
.replacingOccurrences(of: "{y}", with: "\(y)")
|
|
11
|
+
.replacingOccurrences(of: "{z}", with: "\(zoom)")
|
|
12
|
+
return URL(string: urlString)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let layer = GMSURLTileLayer(urlConstructor: constructor)
|
|
16
|
+
|
|
17
|
+
layer.tileSize = Int(t.tileSize)
|
|
18
|
+
t.opacity.map { layer.opacity = Float($0) }
|
|
19
|
+
t.zIndex.map { layer.zIndex = Int32($0) }
|
|
20
|
+
t.fadeIn.map { layer.fadeIn = $0 }
|
|
21
|
+
|
|
22
|
+
return layer
|
|
23
|
+
}
|
|
24
|
+
}
|