我在我的 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)
)
}
像这样使用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()