镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Bug with scrollGesturesEnabledDuringRotateOrZoom = false and rotationGesturesEnabled = false #503

Open

Description

@jeffphp

android-maps-compose 4.3.0

If rotationGesturesEnabled = false and scrollGesturesEnabledDuringRotateOrZoom = false, a zoom (pinch) gesture with a rotation (or crossing fingers) will break the pan/drag gesture and make it lag. It looks like a CancellationException is swallowed internally (caught but not thrown), see : #502

Environment details :
android-maps-compose 4.3.0
doesn't seem to occur on the simulator, please use a real device.

Steps to reproduce :

  • set rotationGesturesEnabled = false and scrollGesturesEnabledDuringRotateOrZoom = false
  • Try to rotate the map with two fingers
  • Try to pan.drag the map, it doesn't move as intended (zoom is not affected somehow)

Workaround :

  • setting rotationGesturesEnabled = false and scrollGesturesEnabledDuringRotateOrZoom = true

Code example :

class RecompositionActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContent {
        val cameraPositionState = rememberCameraPositionState {
            position = defaultCameraPosition
        }
        Box(Modifier.fillMaxSize()) {
            MapsComposeSampleTheme {
                GoogleMapView(
                    modifier = Modifier.matchParentSize(),
                    cameraPositionState = cameraPositionState
                )
            }
        }
    }
}


@Composable
fun GoogleMapView(
    modifier: Modifier = Modifier,
    cameraPositionState: CameraPositionState = rememberCameraPositionState(),
    content: @Composable () -> Unit = {},
) {
    var location by remember { mutableStateOf(singapore) }

    var zoom by remember { mutableStateOf(5f) }

    val context = LocalContext.current
    val singaporeState = MarkerState(position = location)

    val mapProperties = remember {
        MapProperties(
            isBuildingEnabled = false,
            isIndoorEnabled = false,
            isMyLocationEnabled = false,
            isTrafficEnabled = false,
            mapType = MapType.SATELLITE,
        )
    }

    val mapOptions = remember {
        GoogleMapOptions()
            .ambientEnabled(false)
            .mapToolbarEnabled(false)
            .compassEnabled(false)
    }

    val uiSettings = remember {
        MapUiSettings(
            compassEnabled = false,
            indoorLevelPickerEnabled = false,
            mapToolbarEnabled = false,
            myLocationButtonEnabled = false,
            rotationGesturesEnabled = false,
            scrollGesturesEnabledDuringRotateOrZoom = false,
            tiltGesturesEnabled = false,
            zoomControlsEnabled = false,
        )
    }
    
    val mapVisible by remember { mutableStateOf(true) }
    if (mapVisible) {
        // Detect when the map starts moving and print the reason
        LaunchedEffect(cameraPositionState.isMoving) {
            if (cameraPositionState.isMoving) {
                Log.d(TAG, "Map camera started moving due to ${cameraPositionState.cameraMoveStartedReason.name}")
            }
        }

        GoogleMap(
            modifier = modifier.fillMaxSize(),
            cameraPositionState = cameraPositionState,
            googleMapOptionsFactory = {mapOptions},
            onMapLoaded = {},
            properties = mapProperties,
            uiSettings = uiSettings,
            onPOIClick = {
                Log.d(TAG, "POI clicked: ${it.name}")
            }
        ) {
            val markerClick: (Marker) -> Boolean = {
                Log.d(TAG, "${it.title} was clicked")
                cameraPositionState.projection?.let { projection ->
                    Log.d(TAG, "The current projection is: $projection")
                }
                false
            }

            Marker(
                state = singaporeState,
                title = "Marker in Singapore",
                onClick = markerClick
            )

            content()
        }
    }
}

}

Activity

  1. added
    triage meI really want to be triaged.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Jan 6, 2024
  2. cghitathefork commented on May 14, 2024

    @cghitathefork

    We're also facing this issue

  3. added
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    and removed
    triage meI really want to be triaged.
    on Feb 24, 2026
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

    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions