Use map in scrollable column #657
-
|
Hi, My problem is that the map doesn't render at all in a scrollable column. Scaffold(
bottomBar = bottomBar
) { innerPadding ->
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
modifier = Modifier.fillMaxSize()
.padding(innerPadding)
) {
Text("Some Text")
MaplibreMap(baseStyle = BaseStyle.Uri("https://tiles.openfreemap.org/styles/liberty"))
}
}This doesn't: Scaffold(
bottomBar = bottomBar
) { innerPadding ->
Column(
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
modifier = Modifier.fillMaxSize()
.padding(innerPadding)
.verticalScroll(rememberScrollState()) // this is the culprit
) {
Text("Some Text")
MaplibreMap(baseStyle = BaseStyle.Uri("https://tiles.openfreemap.org/styles/liberty"))
}
}It just doesn't render at all. It's not throwing an error or giving any warning. My guess is that the scroll controls of the column interfere with the drag controls of the map. Since I want a static map, this isn't a huge deal since I want to remove dragging for this instance anyway. But why doesn't it even render? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
I’d suggest using the MapSnapshotter — you configure the region you want to display, add the marker, and it generates a Bitmap. Once it’s loaded, you can draw it inside an Image Composable, and you’ll have the picture ready to show as your thumbnail. |
Beta Was this translation helpful? Give feedback.
-
|
I agree with the snapshotter suggestion, though we don't have a KMP wrapper for that yet. For now, you can use the underlying MapLibre Native snapshotter API for the platform(s) you target. But the map not rendering in a scrollable column seems like a bug. Feel free to file an issue for that. |
Beta Was this translation helpful? Give feedback.
I’d suggest using the MapSnapshotter — you configure the region you want to display, add the marker, and it generates a Bitmap. Once it’s loaded, you can draw it inside an Image Composable, and you’ll have the picture ready to show as your thumbnail.