fix(#2094): remove redundant mapView.onDetach() call (#2143)

This commit is contained in:
James Rich 2025-06-17 03:13:00 +00:00 committed by GitHub
parent 6b3ae27c67
commit 27aacd1fbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -90,10 +90,12 @@ internal fun rememberMapViewWithLifecycle(
tileSource: ITileSource = TileSourceFactory.DEFAULT_TILE_SOURCE, tileSource: ITileSource = TileSourceFactory.DEFAULT_TILE_SOURCE,
): MapView { ): MapView {
var savedZoom by rememberSaveable { mutableDoubleStateOf(zoomLevel) } var savedZoom by rememberSaveable { mutableDoubleStateOf(zoomLevel) }
var savedCenter by rememberSaveable(stateSaver = Saver( var savedCenter by rememberSaveable(
save = { mapOf("latitude" to it.latitude, "longitude" to it.longitude) }, stateSaver = Saver(
restore = { GeoPoint(it["latitude"] ?: 0.0, it["longitude"] ?: .0) } save = { mapOf("latitude" to it.latitude, "longitude" to it.longitude) },
)) { mutableStateOf(mapCenter) } restore = { GeoPoint(it["latitude"] ?: 0.0, it["longitude"] ?: .0) }
)
) { mutableStateOf(mapCenter) }
val context = LocalContext.current val context = LocalContext.current
val mapView = remember { val mapView = remember {
@ -155,7 +157,6 @@ internal fun rememberMapViewWithLifecycle(
onDispose { onDispose {
lifecycle.removeObserver(observer) lifecycle.removeObserver(observer)
wakeLock.safeRelease() wakeLock.safeRelease()
mapView.onDetach()
} }
} }
return mapView return mapView