最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - How to specify MarkerInfoWindowContent for my Markers in Compose Maps? - Stack Overflow

programmeradmin4浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论