Pablo
02/10/2025, 5:16 PMPablo
02/10/2025, 5:17 PMListDetailPaneScaffold(
modifier = Modifier.fillMaxSize(),
directive = navigator.scaffoldDirective,
value = navigator.scaffoldValue,
listPane = {
AnimatedPane {
LinesList(
lines = uiState.lines,
onItemClick = { index ->
navigator.navigateTo(ListDetailPaneScaffoldRole.Detail, index)
},
)
}
},
detailPane = {
AnimatedPane {
navigator.currentDestination?.content?.let { index ->
vm.selectLine(uiState.lines[index]) // this set in uiState.mapState the new markers
MapPanel(mapState = uiState.mapState)
}
}
},
)
My map composable:
@Composable
fun MapPanel(
mapState: MapState,
modifier: Modifier = Modifier
) {
val showMarkers: Boolean by remember { derivedStateOf { cameraPositionState.position.zoom > minZoomForVisibleMarkers } } // default 15
val boundsBuilder = LatLngBounds.builder()
GoogleMap(
modifier = modifier.fillMaxSize(),
cameraPositionState = cameraPositionState
) {
val bitmapDescriptor: BitmapDescriptor by remember { mutableStateOf(BitmapDescriptorFactory.fromResource(R.drawable.place)) }
for (busStop in mapState.busStops) {
val markerState = rememberMarkerState(
position = LatLng(busStop.lat, busStop.lon)
)
Marker(
state = markerState,
icon = bitmapDescriptor,
visible = showMarkers,
onClick = {
selectBusStop(busStop)
false
}
)
boundsBuilder.include(markerState.position)
}
if (centerInMarkers && mapState.busStops.isNotEmpty()) {
LaunchedEffect(key1 = true ) {
cameraPositionState.animate(
update = CameraUpdateFactory.newLatLngBounds(bounds, 100)
)
}
}
}
}
Chrimaeon
02/10/2025, 6:02 PMPablo
02/10/2025, 7:43 PMPablo
02/10/2025, 7:44 PMkey(mapState) {}
and suddenly it started working. I don't understand why that makes it recompose correctlyPablo
02/10/2025, 7:45 PM