kotlin - Google map Compose MyLocationButton 未显示

标签 kotlin android-jetpack-compose google-maps-compose

我在 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/

相关文章:

android - 在jetpack compose中显示时如何使文本编号动画?

android - Jetpack Compose 可以用来构建 App Widgets 吗?

android - 很想获得可组合组件的 MeasuredWitdh 和 MeasuredHeight?

android - 如何在Jetpack Compose中实现翻译动画?

android - Dagger2 继承的子组件多重绑定(bind)

Android:有谁知道 Android 的房间数据库是否经过凭证加密?

ios - 带有 Kotlin/Native 的原生 iOS 项目中的 Kotlin 文件