[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"CameraPositionState may only be associated with one GoogleMap at a time" when used with Accompanist's HorizontalPager #106

Closed
nathanjde opened this issue May 3, 2022 · 3 comments · Fixed by #109
Assignees
Labels
released triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@nathanjde
Copy link

Coming across a crash when trying to embed a GoogleMap inside a HorizontalPager when the CameraPositionState is hoisted outside of the pager

Environment details

  • Android Studio Bumblebee 2021.1.1 Patch 3
  • Kotlin 1.6.20
  • Compose 1.2.0-alpha08
  • Accompanist 0.24.7-alpha
  • maps-compose 2.1.0

Steps to reproduce

Stack trace

java.lang.IllegalStateException: CameraPositionState may only be associated with one GoogleMap at a time
    at com.google.maps.android.compose.CameraPositionState.setMap$maps_compose_release(CameraPositionState.kt:144)
    at com.google.maps.android.compose.MapPropertiesNode.<init>(MapUpdater.kt:40)
    at com.google.maps.android.compose.MapUpdaterKt$MapUpdater$1.invoke(MapUpdater.kt:121)
    at com.google.maps.android.compose.MapUpdaterKt$MapUpdater$1.invoke(MapUpdater.kt:119)
    at com.google.maps.android.compose.MapUpdaterKt$MapUpdater$$inlined$ComposeNode$1.invoke(Composables.kt:225)
...
@nathanjde nathanjde added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels May 3, 2022
@jpoehnelt
Copy link
Contributor

@nathanjde Thank you for opening this issue. 🙏
Please check out these other resources that might be applicable:

This is an automated message, feel free to ignore.

@arriolac
Copy link
Contributor
arriolac commented May 5, 2022

There is code that is supposed to disassociate the map with the CameraPositionState object see: https://github.com/googlemaps/android-maps-compose/blob/main/maps-compose/src/main/java/com/google/maps/android/compose/MapUpdater.kt#L95 so I wonder if the GoogleMap composable isn't properly disposing within a horizontal pager/

@googlemaps-bot
Copy link
Contributor

🎉 This issue has been resolved in version 2.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
5 participants