From 50cf8a6986c95efeb471c685a1b8c58849369b25 Mon Sep 17 00:00:00 2001 From: ganfra Date: Thu, 12 Mar 2026 10:28:36 +0100 Subject: [PATCH] Make sure zoom is at least DEFAULT_ZOOM when following user position --- .../features/location/impl/common/ui/UserLocationPuck.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/ui/UserLocationPuck.kt b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/ui/UserLocationPuck.kt index 9a0623a361..f014debe08 100644 --- a/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/ui/UserLocationPuck.kt +++ b/features/location/impl/src/main/kotlin/io/element/android/features/location/impl/common/ui/UserLocationPuck.kt @@ -11,6 +11,7 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.unit.dp import io.element.android.compound.theme.ElementTheme +import io.element.android.features.location.impl.common.MapDefaults import org.maplibre.compose.camera.CameraState import org.maplibre.compose.location.DesiredAccuracy import org.maplibre.compose.location.LocationPuck @@ -33,7 +34,12 @@ fun UserLocationPuck( locationState = locationState, enabled = trackUserLocation, ) { - cameraState.updateFromLocation() + val finalPosition = cameraState.position.copy( + target = currentLocation.position, + bearing = currentLocation.bearing ?: cameraState.position.bearing, + zoom = cameraState.position.zoom.coerceAtLeast(MapDefaults.DEFAULT_ZOOM) + ) + cameraState.animateTo(finalPosition) } val location = locationState.location if (location != null) {