Skip to content

Commit f1110e7

Browse files
committed
fix: mapview onDestroy
1 parent b6c1281 commit f1110e7

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

android/src/main/java/com/rngooglemapsplus/GoogleMapsViewImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,14 +975,14 @@ class GoogleMapsViewImpl(
975975

976976
fun destroyInternal() {
977977
onUi {
978+
locationHandler.stop()
978979
markerBuilder.cancelAllJobs()
979980
clearMarkers()
980981
clearPolylines()
981982
clearPolygons()
982983
clearCircles()
983984
clearHeatmaps()
984985
clearKmlLayer()
985-
locationHandler.stop()
986986
googleMap?.apply {
987987
setOnCameraMoveStartedListener(null)
988988
setOnCameraMoveListener(null)
@@ -1003,6 +1003,7 @@ class GoogleMapsViewImpl(
10031003
}
10041004
super.removeAllViews()
10051005
reactContext.removeLifecycleEventListener(this)
1006+
initialized = false
10061007
}
10071008
}
10081009

ios/GoogleMapViewImpl.swift

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,10 @@ GMSIndoorDisplayDelegate {
629629

630630
@MainActor
631631
func clearHeatmaps() {
632-
heatmapsById.values.forEach { $0.map = nil }
632+
heatmapsById.values.forEach {
633+
$0.clearTileCache()
634+
$0.map = nil
635+
}
633636
heatmapsById.removeAll()
634637
pendingHeatmaps.removeAll()
635638
}
@@ -671,16 +674,21 @@ GMSIndoorDisplayDelegate {
671674
}
672675

673676
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
677+
onMain {
678+
self.locationHandler.stop()
679+
self.markerBuilder.cancelAllIconTasks()
680+
self.clearMarkers()
681+
self.clearPolylines()
682+
self.clearPolygons()
683+
self.clearCircles()
684+
self.clearHeatmaps()
685+
self.clearKmlLayers()
686+
self.mapView?.clear()
687+
self.mapView?.indoorDisplay.delegate = nil
688+
self.mapView?.delegate = nil
689+
self.mapView = nil
690+
self.initialized = false
691+
}
684692
}
685693

686694
@objc private func appDidBecomeActive() {

0 commit comments

Comments
 (0)