admin管理员组

文章数量:1220994

I'm trying to implement Google Maps in Jetpack compose:

GoogleMap(
    modifier = Modifier.fillMaxSize(),
    cameraPositionState = cameraPositionState
) {
    val bitmapDescriptor: BitmapDescriptor by remember { mutableStateOf(BitmapDescriptorFactory.fromResource(R.drawable.place)) }

    for (busStop in uiState.data) {
        Marker(
            state = rememberMarkerState(position = LatLng(busStop.lat, busStop.lon)),
            title = busStop.name,
            snippet = "" + busStop.lat + "," + busStop.lon,
            icon = bitmapDescriptor
        )
    }

    MarkerInfoWindowContent(
        // what should I do here?
    ) { marker ->
        // what should I do here?
        Text(marker.title ?: "Default Marker Title", color = Color.Red)
    }
}

As you can see, I'm adding a list of Markers using that for. Now I need to customize my InfoWindow, I want to specify a custom content for it, but I don't find how to do it. In the official documentation they just say this:

You can customize a marker's info window contents by using the MarkerInfoWindowContent element

MarkerInfoWindowContent(
    //...
) { marker ->
    Text(marker.title ?: "Default Marker Title", color = Color.Red)
}

As you can see documentation is very poor, so I don't have any idea of how to implement my custom infowindow and how to pass it the current marker value.

本文标签: androidHow to specify MarkerInfoWindowContent for my Markers in Compose MapsStack Overflow