Fix a crash in old MapDialog introduced due to updated google maps sdk

This commit is contained in:
Olof Hedman
2025-09-23 12:35:27 +02:00
parent 05bab442bf
commit d9eef1338a

View File

@@ -42,6 +42,7 @@ import com.google.maps.android.compose.MarkerInfoWindow
import com.google.maps.android.compose.MarkerState
import com.google.maps.android.compose.MapUiSettings
import com.google.maps.android.compose.rememberCameraPositionState
import com.google.maps.android.compose.MapEffect
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.tasks.await
import kotlinx.coroutines.withContext
@@ -136,15 +137,6 @@ fun MapDialog(
} else forn = emptyList()
}
LaunchedEffect(myLat, myLon) {
val lat = myLat; val lon = myLon
if (lat != null && lon != null) {
camState.animate(
CameraUpdateFactory.newLatLngZoom(LatLng(lat, lon), 16f)
)
}
}
AlertDialog(
onDismissRequest = onClose,
title = { Text("Karta") },
@@ -168,6 +160,13 @@ fun MapDialog(
compassEnabled = true
)
) {
MapEffect(myLat, myLon) { map ->
val lat = myLat; val lon = myLon
if (lat != null && lon != null) {
map.animateCamera(CameraUpdateFactory.newLatLngZoom(LatLng(lat, lon), 16f))
}
}
val lat = myLat; val lon = myLon
if (showKlotter) {
klotter.forEach { n ->