-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Update model and marker in cluster #90
Comments
This commit makes it possible: 49d42d6 |
i would love to know if there's a solution to updating a model and having the info window refreshed. |
I guess we still need to kill all markers and then re-add them back as new ones, sadness eternal ... |
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() |
@lujop How did you go about overriding |
As I said - if you want to update a single marker, remove the item (not the marker), add the item again, and run
|
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 |
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! |
Hello all, I was facing similar issue when downloading images via Glide. Now it is working fine for me. What I did was call
I have tested a couple of times. But, I would prefer good amount of testing before being sure. |
Like @Shusshu said ,
PlaceRenderer :
PlaceCluster :
|
Thank you @Kolyall !! |
@Kolyall getMarker() always returns null for me. No way to get that code of yours working.. |
idea 2 also worked nice for me
where Person is a
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
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! |
As discussed in #90, when an item instance is removed, updated, and re-added the ClusterManager, the updated item state wouldn't be reflected on the map. The reason for this is that DefaultClusterRenderer.CreateMarkerTask.perform() was using a marker from its own mMarkerCache associated with that item to display that item on the map (even if ClusterManager.clearItems() was previously called). This resulted in the updated item contents not being reflected on the map, because the cached marker was not updated. This PR does the following: * Add new protected methods in DefaultClusterRenderer - onClusterItemUpdated() and onClusterUpdated() - which are called when an existing cached marker is found for an item/cluster when that item/cluster is being added back into the ClusterManager. The default implementation of these methods update the marker contents on the map, but then can also be overridden by applications for custom behavior (similar to onBeforeClusterItemRendered() and onBeforeClusterRendered()). Following this change, you can now do ClusterManager.clearItems() and re-add the same list instance (or remove() and then add() the same item) and then call cluster() and the map markers will be updated with the new item model contents. * Add a new ClusterManager.updateItem() helper method for updating the ClusterManager and algorithms with an existing item. The current implementation in NonHierarchicalDistanceBasedAlgorithm is a wrapper for remove() and then add(). * Add more descriptive Javadocs to ClusterManager, DefaultClusterRenderer, and NonHierarchicalDistanceBasedAlgorithm to describe expected behavior, especially that cluster() should be invoked after any changes to ClusterManager to see changes on the map. * Add boolean return values to Algorithm add/remove/update operations - Implementation follows the Java Collection definitions of the matching methods Refs: 90 Fixes #90
arker marker = getMarker(place);
Marker marker = getMarker(place); |
@nikeru8 Could you please open a new issue with more details so we can better understand the exact issue you're encountering here? Thanks! |
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
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
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 👍
The text was updated successfully, but these errors were encountered: