Skip to content

Cluster - update item didn't change iconΒ #673

@oFFca

Description

@oFFca

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions