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

Does GoogleMap call onClick on MarkerComposable during composition? #611

Open
alghe-global opened this issue Aug 12, 2024 · 0 comments
Open

Comments

@alghe-global
Copy link

Hi,

I'm using com.google.maps.android:maps-compose:5.0.3 with build.gradle.kts in Kotlin 2.0 and latest compiler and Compose.

I'm developing an app where I attached a marker to each object I'm giving as input to a Composable which calls GoogleMap composable.

I'm composing MarkerComposable in two ways:

  1. All objects as input that the user hasn't selected
  2. The object as input the user has selected

To complicate a bit things, I am keeping state regarding which object is the currently selected one in ViewModel.

When a user clicks on the marker in the Map in UI on the device (Android phone, for example), the currently selected object is updated to that marker.

I was updating state even if the Marker was currently the selected one. Removing this code and leaving code to update the currently selected object only in MarkerComposable that are not matching the currently selected seems to have solved the issue where duplicate MarkerComposable were created.

As this is a strange fix for me and one that doesn't really make sense, I've to ask: does GoogleMap call onClick on MarkerComposable during composition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant