如何在 Jetpack Compose 中的 Google 地图标记旁边显示文本

问题描述 投票:0回答:1

我在我的 jetpack compose 项目中使用 Google 地图。我想在标记旁边显示文本。我尝试使用 Marker() 它显示标记但不显示文本。当我单击标记时它会显示文本,但我希望它显示带标记的文本。

    GoogleMap(
    googleMapOptionsFactory = {
        GoogleMapOptions().mapId(MapDefaults.mapId)
    },
    cameraPositionState = cameraPositionState,
    properties = style.mapProperties,
    uiSettings = style.mapUiSettings,
    onMapClick = onMapClick,
    onMapLoaded = onMapLoaded,
) {
    Marker(
        state = MarkerState(position = LatLng(latitude, longitude)),
        title = "Your Marker Title",
        snippet = "Text beside the icon",
        icon = BitmapDescriptorFactory.fromResource(R.drawable.your_icon)
    )
}
google-maps android-jetpack-compose
1个回答
0
投票

像这样使用showInfoWindow

val markerState = rememberMarkerState(null, LatLng(latitude, longitude))
Marker(
    state = markerState,
    title = "Your Marker Title",
    snippet = "Text beside the icon",
    icon = BitmapDescriptorFactory.fromResource(R.drawable.your_icon)
)

markerStatearkerState.showInfoWindow()
© www.soinside.com 2019 - 2024. All rights reserved.