googlemaps / googlemaps/android-maps-compose
Using rememberCameraPositionState and observing it via a lambda, makes entire map recompose instead of just of the lambda
- Dominant language
- Kotlin
- Stars
- 1.3k
- Forks
- 181
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 18
Description
I am using the `rememberCameraPositionState` like so, and then exposing a callback from my custom google map wrapper to observe the state
```
val cameraPositionState =
rememberCameraPositionState {
position =
CameraPosition.fromLatLngZoom(
mapInitialTargetLocation,
14f
)
//Custom callback exposed from map
onMapCameraPositionStateChanged: (CameraPositionState) -> Unit = {},
```
However when I try to use this map, and trigger an operation from the viewModel, it recomposes infinitely
```
fun ParentComposable(){
MapContent(viewModel::onCameraPositionStateChanged)
}
//Calling this function from above parent composable like so
// CustomerMap is my own wrapper around GoogleMap for convenience
private fun MapContent(
onCameraStateChanged : (CameraPositionState) -> Unit
) {
CustomerMap(
......,
onMapCameraPositionStateChanged = onCameraStateChanged
}
```
What am I doing wrong, or is it just a Google Map issue?
Contributor guide
Assessment
This issue has not been assessed yet.