In my Android application, I have to delete and re-add a cluster item in my GoogleMap, that represents my current location. But when I run this code:
clusterMng.remove(myitem);
I get this Exception:
java.lang.UnsupportedOperationException: NonHierarchicalDistanceBasedAlgorithm.remove
not implemented.
Can someone explain to me what this means? Do I have to rewrite some methods of ClusterManager.java in the external library? Or can I simply change my algorithm?
By default ClusterManager uses NonHierarchicalDistanceBasedAlgorithm, that doesn't implement removing elements.
Try to use GridBasedAlgorithm instead (it supports elements remove):
clusterMng.setAlgorithm(new GridBasedAlgorithm<MyClusterItem>());
Or, for better performance, wrap it with PreCachingAlgorithmDecorator, as ClusterManager does by default:
clusterMng.setAlgorithm(new PreCachingAlgorithmDecorator<MyClusterItem>(new GridBasedAlgorithm<MyClusterItem>()));