Open cfbeard opened 10 months ago
I also have this problem "When zooming in, the camera will automatically zoom back out or pan in a random direction."
I encountered this issue and after many attempts, found a temporary working solution.
Instead of:
val cameraState = rememberCameraState {
geoPoint = GeoPoint(60.0, 30.0)
zoom = 14.0
}
Use:
var cameraState by remember {
mutableStateOf(
CameraState(
CameraProperty(
geoPoint = GeoPoint(60.0, 30.0),
zoom = 14.0
)
)
)
}
LaunchedEffect(cameraState.zoom) {
val zoom = cameraState.zoom
val geoPoint = cameraState.geoPoint
cameraState = CameraState(
CameraProperty(
geoPoint = geoPoint,
zoom = zoom
)
)
}
The key is to catch the zoom change event and "recreate" the cameraState before this random drift occurs.
The lines attached below seem to be causing some unexpected zoom and panning issues. When zooming in, the camera will automatically zoom back out or pan in a random direction.
https://github.com/utsmannn/osm-android-compose/blob/8513df0e09c2e5f13e17e15ce9581446ff3025de/osm-compose/src/main/java/com/utsman/osmandcompose/OpenStreetMap.kt#L130-L135