gpt4 book ai didi

android - 获取当前位置按钮未显示在 Jetpack Compose 谷歌地图上

转载 作者:行者123 更新时间:2023-12-02 18:27:22 24 4
gpt4 key购买 nike

我想在 Google map 上显示当前位置按钮 (isMyLocationButtonEnabled),但它没有显示。

如何显示获取当前位置按钮?

AndroidView(
factory = { mapView }
) {
mapView.getMapAsync { map ->
map.apply {
navigatorViewModel.apply {
viewModelScope.launch {
isMapEditable.collectLatest {
uiSettings.setAllGesturesEnabled(
it,
)
uiSettings.isMyLocationButtonEnabled = true
}
}
val location = lastSelectedLocation.value
val position = LatLng(location.latitude, location.longitude)
moveCamera(
CameraUpdateFactory.newLatLngZoom(
position,
Constants.ZOOM_CAMERA
)
)

setOnCameraIdleListener {
val cameraPosition = map.cameraPosition
updateLocation(
cameraPosition.target.latitude,
cameraPosition.target.longitude
)
}
}
}
}
}

最佳答案

添加这些属性:

val uiSettings = remember {
MapUiSettings(myLocationButtonEnabled = true)
}
val properties by remember {
mutableStateOf(MapProperties(isMyLocationEnabled = true))
}

谷歌地图:

 GoogleMap(
modifier = modifier.fillMaxSize(),
cameraPositionState = cameraPositionState,
properties = properties,
uiSettings = uiSettings)

关于android - 获取当前位置按钮未显示在 Jetpack Compose 谷歌地图上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69940303/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com