Я пытаюсь обновить контент Infowindowmarker моей карты Google в Compose , для этого я добавил OnClick в Infowindowmarker and when it's clicked, it changes a "favorite" variable, который поднимается на карте. Эта любимая переменная передается в маркер, и в зависимости от этой переменной показывает или нет другого текста. Режим отладки с перерывом), но информационное окно не изменяется! Любимый текст не появляется, как будто он не подчиняется. < /p>
Это моя карта Google: < /p>
GoogleMap(
modifier = Modifier.fillMaxSize(),
cameraPositionState = cameraPositionState
) {
val bitmapDescriptor: BitmapDescriptor by remember { mutableStateOf(BitmapDescriptorFactory.fromResource(R.drawable.place)) }
for (busStop in uiState.data) {
var favorite by remember { mutableStateOf(false) }
val markerState = rememberMarkerState(position = LatLng(busStop.lat, busStop.lon))
CustomMarker(
favorite = favorite,
busStop = busStop,
markerState = markerState,
bitmapDescriptor = bitmapDescriptor,
showMarker = showMarkers,
onMarkerClicked = { favorite = !favorite }
)
}
}
< /code>
Это мой пользовательский маркировщик: < /p>
@Composable
fun CustomMarker(
favorite: Boolean,
busStop: BusStop,
markerState: MarkerState,
bitmapDescriptor: BitmapDescriptor,
showMarker: Boolean,
onMarkerClicked: () -> Unit,
modifier: Modifier = Modifier
) {
MarkerInfoWindowContent(
state = markerState,
icon = bitmapDescriptor,
visible = (showMarker),
onInfoWindowClick = {
onMarkerClicked()
}
) {
Column(
modifier = modifier.wrapContentSize().padding(8.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Text(text = busStop.id.toString(), color = Color.Red)
Text(text = busStop.name, color = Color.Red)
if (favorite)
Text("favorite"}
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/794 ... ecomposing
MarkerInfowindow не переоценивает ⇐ Android
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение