This is a follow-up to my previous question: ClusterManager isn't redrawing Markers
I've done some investigation and found something interesting. ClusterManager.clearItems()
does not always clear items.
After adding one marker to the ClusterManager
I run this block:
mClusterManager.clearItems();
Log.d(TAG, "Marker list is empty: " + String.valueOf(mClusterManager.getMarkerCollection().getMarkers().isEmpty()));
for (Marker m : mClusterManager.getMarkerCollection().getMarkers()) {
Log.d(TAG, m.getId() + "| " + m.getPosition());
}
Which provides the following output:
02-03 12:30:52.953 14328-14328/com.app.mobile D/app:MapsActivity: Marker list is empty: false
02-03 12:30:52.954 14328-14328/com.app.mobile D/app:MapsActivity: m7| lat/lng: (33.2980945,-111.953964)
It is never empty in spite of clear being called. What's going on here?
If it never empties, is adding an updated m7 Marker
to the ClusterManager
ignored?
Link to Google's implementation of clearItems()
Call the cluster() function just after clearItems()
I ended up discovering that my override implementation of hashCode()
in my implementation of Marker
was causing the usual replace/remove/clear functionality to malfunction.
My solution was to remove my implementation of hashCode()
and work around my need for a custom hash solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With