TradeMe / MapMe

The Android maps adapter
MIT License
841 stars 75 forks source link

Support for Clustering? #12

Open The0ldM0nk opened 6 years ago

The0ldM0nk commented 6 years ago

So, is clustering supported out-of-the-box? Looking forward to it :)

josh-burton commented 6 years ago

Hi, there is no direct support for clustering, although this is something you could achieve by manipulating your data.

Since MapMe adapters support multiple annotation types, you could define a type for a cluster, and organise your data into clusters.

I'd be interested to hear what features you would like to see for clustering?

dellisd commented 6 years ago

This may go beyond the scope of this library, but adding a set of classes to automatically create some kind of ClusterAnnotation would be useful. You could run your data points through some sort of function (kind of like running a DiffUtil) which would generate clusters of points which could then be sent to the adapter.

This would probably be best to do on a per-project basis but, the way I see it since clustering markers is such a common need for apps, including it in the library would be quite beneficial.

trevjonez commented 6 years ago

as a base level setup for the clustering you can use the NonHierarchicalDistanceBasedAlgorithm from com.google.maps.android:android-maps-utils:0.5. The getClusters(zoom) will return a set of Cluster objects. In my case I unwrap any cluster item that is a single item and let my original pin data representation through. In the other cases my pluggable version of the mapme adapter just gets told how to render the StaticCluster type that the cluster algorithm produces for actual clusters. It returns a private class implementation of Cluster called QuadItem when it is a single item.