Skip to content

Commit

Permalink
fix: Prevent Clustering with composable content from displaying defau…
Browse files Browse the repository at this point in the history
…lt markers (#615)

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.
  • Loading branch information
darronschall authored Nov 5, 2024
1 parent f7f4854 commit 95c6306
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ import kotlinx.coroutines.launch
clusterManager.setOnClusterItemInfoWindowClickListener(onClusterItemInfoWindowClick)
clusterManager.setOnClusterItemInfoWindowLongClickListener(onClusterItemInfoWindowLongClick)
}
if (clusterManager != null) {
// Wait for renderer to apply before clustering
if (clusterManager != null && clusterManager.renderer == clusterRenderer) {
Clustering(
items = items,
clusterManager = clusterManager,
Expand Down Expand Up @@ -128,21 +129,22 @@ public fun <T : ClusterItem> Clustering(
) {
val clusterManager = rememberClusterManager<T>()
val renderer = rememberClusterRenderer(clusterContent, clusterItemContent, clusterManager)
SideEffect {
if (clusterManager?.renderer != renderer) {
clusterManager?.renderer = renderer ?: return@SideEffect
}
}

SideEffect {
clusterManager ?: return@SideEffect
renderer ?: return@SideEffect

if (clusterManager.renderer != renderer) {
clusterManager.renderer = renderer
}

clusterManager.setOnClusterClickListener(onClusterClick)
clusterManager.setOnClusterItemClickListener(onClusterItemClick)
clusterManager.setOnClusterItemInfoWindowClickListener(onClusterItemInfoWindowClick)
clusterManager.setOnClusterItemInfoWindowLongClickListener(onClusterItemInfoWindowLongClick)
}

if (clusterManager != null) {
if (clusterManager != null && renderer != null) {
Clustering(
items = items,
clusterManager = clusterManager,
Expand Down

0 comments on commit 95c6306

Please sign in to comment.