Fix crash in GoogleMaps component due to new maps library version

This commit is contained in:
Olof Hedman
2025-09-23 14:50:06 +02:00
parent 5d8d620811
commit 4e9b5b34c7

View File

@@ -161,6 +161,7 @@ import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.model.CameraPosition import com.google.android.gms.maps.model.CameraPosition
import com.google.android.gms.maps.model.LatLng import com.google.android.gms.maps.model.LatLng
import com.google.maps.android.compose.GoogleMap import com.google.maps.android.compose.GoogleMap
import com.google.maps.android.compose.MapEffect
import com.google.maps.android.compose.MapProperties import com.google.maps.android.compose.MapProperties
import com.google.maps.android.compose.MapType import com.google.maps.android.compose.MapType
import com.google.maps.android.compose.MapUiSettings import com.google.maps.android.compose.MapUiSettings
@@ -1233,14 +1234,6 @@ private fun WriteDocDialog(
val lon = selectedLon ?: 18.0686 val lon = selectedLon ?: 18.0686
position = CameraPosition.fromLatLngZoom(LatLng(lat, lon), 20f) // max-zoom position = CameraPosition.fromLatLngZoom(LatLng(lat, lon), 20f) // max-zoom
} }
LaunchedEffect(selectedLat, selectedLon) {
val lat = selectedLat; val lon = selectedLon
if (lat != null && lon != null) {
camState.animate(
CameraUpdateFactory.newLatLngZoom(LatLng(lat, lon), 20f)
)
}
}
val satellite = SettingsStore.getSatelliteMap() val satellite = SettingsStore.getSatelliteMap()
AlertDialog( AlertDialog(
@@ -1275,6 +1268,11 @@ private fun WriteDocDialog(
zoomGesturesEnabled = false zoomGesturesEnabled = false
) )
) { ) {
var position = LatLng(selectedLat!!, selectedLon!!)
MapEffect(position) { map ->
map.animateCamera(CameraUpdateFactory.newLatLngZoom(position, 16f))
}
Marker(state = MarkerState(position = LatLng(selectedLat!!, selectedLon!!))) Marker(state = MarkerState(position = LatLng(selectedLat!!, selectedLon!!)))
} }
} }