我使用official谷歌Map合成库,我不明白...如何实现点击标记?
@Composable
fun MapContent(city: City) {
val pos = LatLng(city.latitude, city.longitude)
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(pos, 12f)
}
val mapState = rememberMarkerState(position = pos)
GoogleMap(
modifier = Modifier.fillMaxSize(),
cameraPositionState = cameraPositionState,
uiSettings = MapUiSettings(zoomControlsEnabled = false)
) {
Marker(
state = mapState,
onClick = {
Timber.tag("GoogleMapClick").d("click!!!")
false
}
)
}
}
它不起作用。您能帮助我吗?出了什么问题?我想单击标记并显示包含城市信息的BottomSheet,但似乎onClick不起作用...
implementation 'com.google.maps.android:maps-compose:2.5.3'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
1条答案
按热度按时间6yjfywim1#
您应该使用
onInfoWindowClick
而不是onClick
这是我的代码)