react-native-google-maps-plus 1.3.0-dev.3 → 1.3.0

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.
@@ -153,9 +153,9 @@ class GoogleMapsViewImpl(
153
153
  }
154
154
  initLocationCallbacks()
155
155
  applyPending()
156
+ mapReady = true
157
+ onMapReady?.invoke(true)
156
158
  }
157
- mapReady = true
158
- onMapReady?.invoke(true)
159
159
  }
160
160
 
161
161
  override fun onCameraMoveStarted(reason: Int) {
@@ -372,6 +372,8 @@ class GoogleMapsViewImpl(
372
372
  }
373
373
  }
374
374
 
375
+ var initialProps: RNInitialProps? = null
376
+
375
377
  var uiSettings: RNMapUiSettings? = null
376
378
  set(value) {
377
379
  field = value
@@ -975,6 +977,7 @@ class GoogleMapsViewImpl(
975
977
 
976
978
  fun destroyInternal() {
977
979
  onUi {
980
+ locationHandler.stop()
978
981
  markerBuilder.cancelAllJobs()
979
982
  clearMarkers()
980
983
  clearPolylines()
@@ -982,7 +985,6 @@ class GoogleMapsViewImpl(
982
985
  clearCircles()
983
986
  clearHeatmaps()
984
987
  clearKmlLayer()
985
- locationHandler.stop()
986
988
  googleMap?.apply {
987
989
  setOnCameraMoveStartedListener(null)
988
990
  setOnCameraMoveListener(null)
@@ -1003,6 +1005,7 @@ class GoogleMapsViewImpl(
1003
1005
  }
1004
1006
  super.removeAllViews()
1005
1007
  reactContext.removeLifecycleEventListener(this)
1008
+ initialized = false
1006
1009
  }
1007
1010
  }
1008
1011
 
@@ -21,6 +21,7 @@ import com.rngooglemapsplus.extensions.toSize
21
21
  class RNGoogleMapsPlusView(
22
22
  val context: ThemedReactContext,
23
23
  ) : HybridRNGoogleMapsPlusViewSpec() {
24
+ private var propsInitialized = false
24
25
  private var currentCustomMapStyle: String? = null
25
26
  private var permissionHandler = PermissionHandler(context)
26
27
  private var locationHandler = LocationHandler(context)
@@ -35,15 +36,23 @@ class RNGoogleMapsPlusView(
35
36
  override val view =
36
37
  GoogleMapsViewImpl(context, locationHandler, playServiceHandler, markerBuilder)
37
38
 
39
+ override fun afterUpdate() {
40
+ super.afterUpdate()
41
+ if (!propsInitialized) {
42
+ propsInitialized = true
43
+ view.initMapView(
44
+ initialProps?.mapId,
45
+ initialProps?.liteMode,
46
+ initialProps?.camera?.toCameraPosition(),
47
+ )
48
+ }
49
+ }
50
+
38
51
  override var initialProps: RNInitialProps? = null
39
52
  set(value) {
40
53
  if (field == value) return
41
54
  field = value
42
- view.initMapView(
43
- value?.mapId,
44
- value?.liteMode,
45
- value?.camera?.toCameraPosition(),
46
- )
55
+ view.initialProps = value
47
56
  }
48
57
 
49
58
  override var uiSettings: RNMapUiSettings? = null
@@ -198,6 +198,11 @@ GMSIndoorDisplayDelegate {
198
198
  mapView?.camera
199
199
  }
200
200
 
201
+ @MainActor
202
+ var initialProps: RNInitialProps? {
203
+ didSet {}
204
+ }
205
+
201
206
  @MainActor
202
207
  var uiSettings: RNMapUiSettings? {
203
208
  didSet {
@@ -629,7 +634,10 @@ GMSIndoorDisplayDelegate {
629
634
 
630
635
  @MainActor
631
636
  func clearHeatmaps() {
632
- heatmapsById.values.forEach { $0.map = nil }
637
+ heatmapsById.values.forEach {
638
+ $0.clearTileCache()
639
+ $0.map = nil
640
+ }
633
641
  heatmapsById.removeAll()
634
642
  pendingHeatmaps.removeAll()
635
643
  }
@@ -671,16 +679,21 @@ GMSIndoorDisplayDelegate {
671
679
  }
672
680
 
673
681
  func deinitInternal() {
674
- markerBuilder.cancelAllIconTasks()
675
- clearMarkers()
676
- clearPolylines()
677
- clearPolygons()
678
- clearCircles()
679
- clearHeatmaps()
680
- locationHandler.stop()
681
- mapView?.clear()
682
- mapView?.delegate = nil
683
- mapView = nil
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
+ }
684
697
  }
685
698
 
686
699
  @objc private func appDidBecomeActive() {
@@ -696,9 +709,6 @@ GMSIndoorDisplayDelegate {
696
709
  override func didMoveToWindow() {
697
710
  super.didMoveToWindow()
698
711
  if window != nil {
699
- if mapView != nil && mapReady {
700
- onMapReady?(true)
701
- }
702
712
  locationHandler.start()
703
713
  } else {
704
714
  locationHandler.stop()
@@ -8,6 +8,7 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
8
8
  private let permissionHandler: PermissionHandler
9
9
  private let locationHandler: LocationHandler
10
10
 
11
+ private var propsInitialized = false
11
12
  private let markerBuilder = MapMarkerBuilder()
12
13
  private let polylineBuilder = MapPolylineBuilder()
13
14
  private let polygonBuilder = MapPolygonBuilder()
@@ -29,21 +30,23 @@ final class RNGoogleMapsPlusView: HybridRNGoogleMapsPlusViewSpec {
29
30
  )
30
31
  }
31
32
 
32
- /*
33
- /// TODO: prepareForRecycle
34
- override func prepareForRecycle() {
35
- impl.clearAll()
36
- }
37
- */
33
+ func afterUpdate() {
34
+ if !propsInitialized {
35
+ propsInitialized = true
36
+ Task { @MainActor in
37
+ impl.initMapView(
38
+ mapId: self.initialProps?.mapId,
39
+ liteMode: self.initialProps?.liteMode,
40
+ camera: self.initialProps?.camera?.toGMSCameraPosition(current: nil)
41
+ )
42
+ }
43
+ }
44
+ }
38
45
 
39
46
  @MainActor
40
47
  var initialProps: RNInitialProps? {
41
48
  didSet {
42
- impl.initMapView(
43
- mapId: initialProps?.mapId,
44
- liteMode: initialProps?.liteMode,
45
- camera: initialProps?.camera?.toGMSCameraPosition(current: nil)
46
- )
49
+ impl.initialProps = initialProps
47
50
  }
48
51
  }
49
52
 
@@ -49,6 +49,13 @@ using namespace margelo::nitro::rngooglemapsplus::views;
49
49
  return self;
50
50
  }
51
51
 
52
+ /// added by nitrogen-patch.js
53
+ + (BOOL)shouldBeRecycled
54
+ {
55
+ return NO;
56
+ }
57
+
58
+
52
59
  - (void) updateView {
53
60
  // 1. Get Swift part
54
61
  RNGoogleMapsPlus::HybridRNGoogleMapsPlusViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-google-maps-plus",
3
- "version": "1.3.0-dev.3",
3
+ "version": "1.3.0",
4
4
  "description": "React-native wrapper for android & IOS google maps sdk",
5
5
  "main": "./lib/module/index.js",
6
6
  "module": "./lib/module/index.js",