Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Compose MyLocationButton not shown

I have followed a simple tutorial on how to displaying google maps with jetpack compose in the documentation.

But the MyLocationButton still does not showing up.

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"
       )
 }
like image 735
Denny Kurniawan Avatar asked Oct 12 '25 04:10

Denny Kurniawan


1 Answers

You have to add the properties of the GoogleMap:

GoogleMap(properties = MapProperties(isMyLocationEnabled = true)) 
like image 163
Adrian Alejandro Souto Morales Avatar answered Oct 15 '25 00:10

Adrian Alejandro Souto Morales



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!