Skip to content

CameraState.animateTo() completes without moving the camera #1119

Description

@maximeg

What happened?

cameraState.animateTo(newPosition) returns normally, but cameraState.position never changes, map does not move. No exception, no crash, no log output. Reproduces identically on Android and iOS.

cameraState.jumpTo(boundingBox, ...) shows the same symptom (initial bounds fit never applies).

Direct assignment (cameraState.position = newPosition) works reliably as a workaround. Having duration = Duration.ZERO works also.

Affected Platforms

  • Android
  • iOS
  • Desktop - macOS (JVM)
  • Desktop - Linux (JVM)
  • Desktop - Windows (JVM)
  • Browser (JS)
  • Browser (Wasm)

Platform Version

Android 14 (physical device), iOS 17+ (simulator/device)

Library Version

0.15.0

Sample Code

@Composable
fun MyMap() {
    val cameraState = rememberCameraState(firstPosition = CameraPosition(
        target = Position(longitude = 2.3522, latitude = 48.8566),
        zoom = 10.0,
    ))
    val scope = rememberCoroutineScope()

    Column {
        MaplibreMap(
            modifier = Modifier.fillMaxWidth().height(400.dp),
            cameraState = cameraState,
        )
        Button(onClick = {
            scope.launch {
                cameraState.animateTo(
                    CameraPosition(
                        target = Position(longitude = -0.1276, latitude = 51.5072),
                        zoom = 10.0,
                    )
                )
                // cameraState.position still equals the Paris position here.
            }
        }) {
            Text("Fly to London")
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    maplibre-nativeRelates to the MapLibre Native engine used by Android, iOS, and Desktopneed infoRequested feedback from the issue reporter

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions