googlemaps / android-maps-compose

Jetpack Compose composables for the Maps SDK for Android
https://developers.google.com/maps/documentation/android-sdk/maps-compose
Apache License 2.0
1.16k stars 143 forks source link

GoogleMap compose isMyLocationEnabled = true cannot show correctly user location #602

Closed YusufbekIbragimov closed 4 months ago

YusufbekIbragimov commented 4 months ago

Environment details

  1. Specify the API at the beginning of the title (for example, "Places: ...") Android version: 14 Android model: Samsung S23 FE
  2. Library version and other environment information Library versions: mapsCompose = "5.0.0" playServicesMaps = "19.0.0"

My code example:

@Composable
private fun MapContent(
    modifier: Modifier,
    cameraPosition: CameraPositionState,
    uiState: BranchesUiState,
    onAction: OnAction
) {
    val context = LocalContext.current

    GoogleMap(
        modifier = modifier,
        cameraPositionState = cameraPosition,
        properties = MapProperties(isMyLocationEnabled = uiState.isShowUserLocation),
        contentPadding = PaddingValues(
            top = 90.dp + WindowInsets.navigationBars.asPaddingValues().calculateTopPadding(),
            bottom = 180.dp + WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding()
        ),
        uiSettings = MapUiSettings(
            myLocationButtonEnabled = true,
            zoomControlsEnabled = false,
        )
    ) {
        uiState.branches.forEach { branch ->
            Marker(
                state = MarkerState(LatLng(branch.latitude, branch.longitude)),
                icon = BitmapDescriptorFactory.fromBitmap(
                    getBitmapFromVectorDrawable(
                        context,
                        branch.type.getIconResId(branch.isOpen)
                    )
                ),
                onClick = {
                    onAction(UiAction.BranchClicked(branch))
                    true
                }
            )
        }
    }
}

Thanks!