@maydon_tech/react-native-nitro-maps 0.2.1 → 0.2.2

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.
@@ -72,8 +72,14 @@ class HybridNitroMap(context: Context) : HybridNitroMapSpec() {
72
72
  }
73
73
 
74
74
  private fun attachMapView() {
75
- if (currentMapView != null) return // already attached
75
+ if (currentMapView != null) {
76
+ // Reattaching — reuse existing MapView, just resume it
77
+ mapProvider.onViewAttached(currentMapView!!)
78
+ Log.d(TAG, "MapView reattached (resumed)")
79
+ return
80
+ }
76
81
 
82
+ // First time — create and add to container
77
83
  val mv = mapProvider.createMapView(mapContext)
78
84
  container.addView(mv, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)
79
85
 
@@ -81,16 +87,15 @@ class HybridNitroMap(context: Context) : HybridNitroMapSpec() {
81
87
  mapProvider.onViewAttached(mv)
82
88
  }
83
89
  currentMapView = mv
84
- Log.d(TAG, "MapView attached")
90
+ Log.d(TAG, "MapView created and attached")
85
91
  }
86
92
 
87
93
  private fun detachMapView() {
88
- currentMapView?.let { mv ->
89
- mapProvider.onViewDetaching()
90
- container.removeView(mv)
91
- }
92
- currentMapView = null
93
- Log.d(TAG, "MapView detached (paused, state saved)")
94
+ if (currentMapView == null) return
95
+ mapProvider.onViewDetaching()
96
+ // Keep currentMapView and the view in the container — reuse on reattach.
97
+ // The MapView and GoogleMap survive pause/resume cycles.
98
+ Log.d(TAG, "MapView paused (preserved for reattach)")
94
99
  }
95
100
 
96
101
  override fun dispose() {
@@ -67,6 +67,14 @@ class GoogleMapProvider(internal val context: Context) : MapProviderInterface {
67
67
 
68
68
  override fun onViewAttached(view: View) {
69
69
  val mv = view as NitroMapView
70
+ if (isMapReady && googleMap != null) {
71
+ // Resuming from detach — GoogleMap is still valid, just resume the MapView
72
+ mv.onStart()
73
+ mv.onResume()
74
+ Log.d(TAG, "MapView resumed — GoogleMap still valid")
75
+ return
76
+ }
77
+ // First attach — need async init
70
78
  mv.getMapAsync { googleMap ->
71
79
  onMapReady(googleMap, mv)
72
80
  }
@@ -74,14 +82,12 @@ class GoogleMapProvider(internal val context: Context) : MapProviderInterface {
74
82
 
75
83
  override fun onViewDetaching() {
76
84
  mapView?.let { mv ->
77
- val state = Bundle()
78
- mv.onSaveInstanceState(state)
79
- savedState = state
80
85
  mv.onPause()
81
86
  mv.onStop()
82
87
  }
83
- onMapDetaching()
84
- mapView = null
88
+ // Keep mapView, googleMap, isMapReady, and all rendered objects alive.
89
+ // GoogleMap and its native markers/overlays survive pause/resume cycles.
90
+ Log.d(TAG, "MapView paused — all state preserved for reattach")
85
91
  }
86
92
 
87
93
  override fun onViewDestroying() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maydon_tech/react-native-nitro-maps",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "A high-performance React Native map library powered by Nitro Modules with support for Apple Maps, Google Maps, and Yandex Maps. Features native clustering, custom markers, and seamless cross-platform integration.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",