android-maps-compose icon indicating copy to clipboard operation
android-maps-compose copied to clipboard

Cluster - update item didn't change icon

Open oFFca opened this issue 11 months ago • 1 comments

Hi, I'm using Google Maps Compose + Clustering.

I have standard case, I have markers (icon) and whenever I click on it I would like to change this icon.

Environment details

  1. maps-compose and maps-compose-utils v4.3.3
  2. Android 10, 15

Steps to reproduce

  1. Add markers
  2. Update item

Code example

	LaunchedEffect(selectedLocationId) {
		clusterManager ?: return@LaunchedEffect
		clusterManager.algorithm.items.firstOrNull { it.location.id == selectedLocationId }?.let { selectedItem ->
			clusterManager.updateItem(selectedItem.copy(selected = true))
			clusterManager.cluster()
		}
	}


val renderer = rememberClusterRenderer(clusterContent, clusterItemContent, clusterManager)

From my point of view, whenever i called updateItem clusterItemContent or clusterContent should be called whenever item is different then it was.

Whenever i change code to:

	LaunchedEffect(selectedLocationId) {
		clusterManager ?: return@LaunchedEffect
		clusterManager.algorithm.items.firstOrNull { it.location.id == selectedLocationId }?.let { selectedItem ->
                         clusterManager.removeItem(selectedItem)
                         clusterManager.cluster()
                         delay(5000)
			clusterManager.updateItem(selectedItem.copy(selected = true))
			clusterManager.cluster()
		}
	}

It works and i have new icon, however it's not accepted.

I also wanted to extend ComposeUiClusterRenderer and override onClusterItemUpdated but from unknown reason class is internal and i can't do that.

What is the correct way to just update a marker?

oFFca avatar Jan 24 '25 15:01 oFFca

Image

Looks like if your item list changes, it would handle it out of the box as similar logic is handled from within the library.

mahmood-meesho avatar Apr 24 '25 22:04 mahmood-meesho