Repository navigation
Description
When you put your model objects/items into the cluster manager, it will create the markers and group them to clusters if necessary. This is awesome!!
But what if the items change and upon this change you want to have different marker?
Idea 1 (Ideal)
Update the api with an
updateItem(Item)
method. Its the same instance of the added item but has updated attributes.
Idea 2
What I first tried was just replacing the item list
getMap().clear();
mClusterManager.clearItems()
mClusterManager.addItems(items);
mClusterManager.cluster();
This worked only for visible clusters when map was zoomed out. However when map was zoomed in, visible map markers were removed by the above code. You have to zoom out until cluster appears and zoom in again to see the markers.
Idea 3
Currently I am doing this, completely reinitiate the clusterManager when I need to update models and markers. I am not dealing with so much markers (max 200).
@broady Is this ok regarding performance/memory? Nevertheless the cluster api could need some rewrite 👍
Activity
[-]Update model and marker[/-][+]Update model and marker in cluster[/+]Shusshu commentedon Aug 11, 2014
This commit makes it possible: 49d42d6
Flyview commentedon May 26, 2015
@Shusshu How? I am having the same problem with clearing items and adding them back. Please see this issue: #168
stahlnow commentedon Apr 8, 2017
i would love to know if there's a solution to updating a model and having the info window refreshed.
dxshindeo commentedon Apr 25, 2017
I guess we still need to kill all markers and then re-add them back as new ones, sadness eternal ...
lujop commentedon May 18, 2017
I can confirm that Idea 2 works correctly. In fact I can confirm that removeItem()+addItem()+cluster() works correctly if you have a correct Renderer.
You must ensure you use a custom renderer that overrides onClusterItemRendered() and onClusterRendered()
Default renderer only uses onBeforeClusterRendered() that is only called once to create the initial marker.
xsorifc28 commentedon Jun 24, 2017
@lujop How did you go about overriding
onClusterItemRendered()andonClusterRendered()? I'm trying to re-draw a marker after it's position changes. The new position will show if I zoom in/out but not if I'm zoomed in to the marker level.cluster()works on clusters, but not individual markers.dxshindeo commentedon Jun 25, 2017
As I said - if you want to update a single marker, remove the item (not the marker), add the item again, and run
cluster()- the function gets the updated set of items from its array and then refreshes all of its markers on the map.In nativescript:
Murtowski commentedon Jul 26, 2017
By me object it it still not working correctly
I Use
camerUpdateListener
In run time I delivere different list of CluterItems to my function, after animated zoom, sometimes some of markers are not visible - until i zoom out/in (force cluter algorithm to run). A assume that clearItems if also woring inpredictable - sometimes remove more soetimes less items
paduy commentedon Aug 1, 2017
I also cannot refresh marker icons, the "java.lang.IllegalArgumentException: Unmanaged descriptor" always appears when I try to get a marker from Renderer and setIcon for it. Thanks!
holakeshav commentedon Mar 7, 2018
Hello all,
I was facing similar issue when downloading images via Glide.
Now it is working fine for me.
What I did was call
mClusterManager.cluster();after all images were downloaded inonPostExecute.I have tested a couple of times. But, I would prefer good amount of testing before being sure.
Kolyall commentedon Jun 27, 2018
Like @Shusshu said ,
getMarker()can solve the issueIn my case it looks like this:
In Activity:
PlaceRenderer :
PlaceCluster :
mitchtabian commentedon Sep 6, 2018
Thank you @Kolyall !!
Making a "setUpdateMarker" method worked perfectly in my Renderer!
SimonHaenle2 commentedon Jun 4, 2019
@Kolyall getMarker() always returns null for me. No way to get that code of yours working..
alboteanud commentedon Jul 22, 2019
idea 2 also worked nice for me
`
val persons: HashMap<String, Person> = hashMapOf()
where Person is a
data class Person(val userDoc: QueryDocumentSnapshot) : ClusterItem { ...1 remaining item
stale commentedon Jan 1, 2020
This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!
feat(cluster): Support updating existing items (#627)
nikeru8 commentedon Jul 18, 2022
arker marker = getMarker(place);
Marker marker = getMarker(place);
DefaultClusterRenderer getMarker() returning null when zooming
barbeau commentedon Jul 18, 2022
@nikeru8 Could you please open a new issue with more details so we can better understand the exact issue you're encountering here? Thanks!