Home > OS >  How to use the new android-maps-compose library in a scrollable Column?
How to use the new android-maps-compose library in a scrollable Column?

Time:03-05

I just switched from google maps with AndroidView to this compose library (https://github.com/googlemaps/android-maps-compose), and I can't get the scrolling to work properly. I used to use this one:

map.setOnCameraMoveStartedListener {
     mapView?.parent?.requestDisallowInterceptTouchEvent(true)  
}
map.setOnCameraIdleListener {
     mapView?.parent?.requestDisallowInterceptTouchEvent(false)  
}

What would be a similar solution in the new library?

GoogleMap(
properties = mapProperties,
cameraPositionState = cameraPositionState,
modifier = Modifier.clip(MaterialTheme.shapes.medium),
uiSettings = MapUiSettings(mapToolbarEnabled = false)
)

CodePudding user response:

As of version 1.2.0 of Maps Compose, calling requestDisallowInterceptTouchEvent is not possible on those events as Maps Compose completely manages the underlying map. There is an existing issue on the Maps Compose GitHub library (https://github.com/googlemaps/android-maps-compose/issues/14) for this which you can follow.

CodePudding user response:

I successfully solved it with cameraPositionState:

Column(
    .verticalScroll(rememberScrollState(), enabled = !cameraPositionState.isMoving)
)
  • Related