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

fix: Prevent Clustering with composable content from displaying default markers #615

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

darronschall
Copy link

Thank you for opening a Pull Request!


Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open a GitHub issue as a bug/feature request before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #569 🦕

…lt markers

Wait until we have both a non-null clusterManager and renderer created before configuring the cluster manager listeners. This is a small optimization that prevents setting the listeners on the default renderer when the clusterManger is first created (before the renderer is created).

Wait until the renderer is created before configuring the map for clustering. This prevents the default renderer from rendering markers.
@kikoso
Copy link
Collaborator

kikoso commented Aug 29, 2024

Hi @darronschall , and thank you for this PR!

Upon further checking it, it seems that using the two separate SideEffect blocks could have lead to race conditions, hence the reports on why this was not always reproducible. The explicit null check makes also the code safer in case of a race condition.

I am still not able to reproduce it, but this should fix a potential concurrency issue.

@kikoso
Copy link
Collaborator

kikoso commented Aug 29, 2024

Probably fixes #549

@gmazzotta-bit
Copy link

gmazzotta-bit commented Aug 29, 2024

I'd update this too:

val clusterManager = rememberClusterManager<T>()
LaunchedEffect(clusterManager, clusterRenderer) {
clusterManager?.renderer = clusterRenderer
}
SideEffect {
clusterManager ?: return@SideEffect
clusterManager.setOnClusterClickListener(onClusterClick)
clusterManager.setOnClusterItemClickListener(onClusterItemClick)
clusterManager.setOnClusterItemInfoWindowClickListener(onClusterItemInfoWindowClick)
clusterManager.setOnClusterItemInfoWindowLongClickListener(onClusterItemInfoWindowLongClick)
}
if (clusterManager != null) {
Clustering(
items = items,
clusterManager = clusterManager,
)
}

@gmazzotta-bit
Copy link

By the way, as I mentioned here, I really believe this is a bug in DefaultClusterRenderer, but this change should be enough to work around that.

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

Successfully merging this pull request may close these issues.

Clustering sometimes show default markers
4 participants