googlemaps / googlemaps/android-maps-compose

Jetpack Compose Map throwing this when TalkBack is turned on. -> java.lang.IllegalStateException: LayoutNode should be attached to an owner

Open
#404 7 comments 4 reactions 0 assignees View on GitHub
priority: p0 type: bug
Dominant language
Kotlin
Stars
1.3k
Forks
181
Avg merge
2d 23h
Merged PRs (30d)
18

Description

Library version and other environment information
```
composeBOMVersion = "2023.06.01"
composeCompilerVersion="1.4.0-alpha02"
composeNavigationVersion = "2.5.3"

implementation 'com.google.maps.android:maps-compose:2.14.1'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
```

#### Steps to reproduce
Turn on Talk back and Navigate to This compose

When TalkBack is turned off, the app works as expected

Crash Report
![Screenshot 2023-09-22 at 11 36 16 am](https://github.com/googlemaps/android-maps-compose/assets/2536705/30b16657-5d85-4c3f-b37c-909ec1aefe15)

Code:
```

@Composable
fun LocationPickerScreen(
uiState: LocationPickerScreenContract.UiState,
) {

val configuration = LocalConfiguration.current

val screenHeight = configuration.screenHeightDp.dp

val currentLoc = uiState.locationInfo.addressLatLng

val cameraState = rememberCameraPositionState()

LaunchedEffect(key1 = currentLoc) {
cameraState.centerOnLocation(currentLoc)
}

val marker = LatLng(currentLoc.latitude, currentLoc.longitude)

Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colors.background
) {
Box(
modifier = Modifier.fillMaxSize()
) {
GoogleMap(
modifier = Modifier
.fillMaxWidth()
.height(screenHeight - 300.dp)
.align(Alignment.TopCenter),
cameraPositionState = cameraState,
properties = MapProperties(
isMyLocationEnabled = true,
mapType = MapType.HYBRID,
isTrafficEnabled = true
)
) {
Marker(
state = MarkerState(position = marker),
title = "MyPosition",
snippet = "This is a description of this Marker",
draggable = true
)
}

Column(
modifier = Modifier
.fillMaxWidth()
.height(308.dp)
.align(Alignment.BottomCenter),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {

Text(
text = "Data Place Holder",
modifier = Modifier
.semantics {
contentDescription = "data"
}
.padding(bottom = 8.dp),
style = MaterialTheme.typography.body2.copy(
fontSize = 14.sp,
fontWeight = FontWeight.SemiBold,
lineHeight = 16.sp
),
)
}
}
}
}

private suspend fun CameraPositionState.centerOnLocation(
location: LatLng
) = animate(
update = CameraUpdateFactory.newLatLngZoom(
location,
15f
),
durationMs = 1500
)
```
![Screenshot 2023-09-22 at 11 25 23 am](https://github.com/googlemaps/android-maps-compose/assets/2536705/182d4c5b-97a6-4609-a464-49f5aa4920f5)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.