我在 documentation 中遵循了有关如何使用 jetpack compose 显示谷歌地图的简单教程。 .
但是 MyLocationButton 仍然没有显示。
val singapore = LatLng(1.35, 103.87)
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(singapore, 17f)
}
var uiSettings by remember { mutableStateOf(
MapUiSettings(
myLocationButtonEnabled = true,
zoomControlsEnabled = false
)
) }
GoogleMap(
modifier = Modifier.fillMaxSize(),
cameraPositionState = cameraPositionState,
uiSettings = uiSettings,
onMyLocationButtonClick = {
true
}
) {
Marker(
state = MarkerState(position = singapore),
title = "Singapore",
snippet = "Marker in Singapore"
)
}
最佳答案
您必须添加 GoogleMap 的属性:
GoogleMap(properties = MapProperties(isMyLocationEnabled = true))
关于kotlin - Google map Compose MyLocationButton 未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74038156/