Class ClusterManager
-
- All Implemented Interfaces:
-
com.google.android.gms.maps.GoogleMap.OnCameraIdleListener,com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener,com.google.android.gms.maps.GoogleMap.OnMarkerClickListener
public class ClusterManager<T extends ClusterItem> implements GoogleMap.OnCameraIdleListener, GoogleMap.OnMarkerClickListener, GoogleMap.OnInfoWindowClickListenerGroups many items on a map based on zoom level.
ClusterManager should be added to the map as an:
com.google.android.gms.maps.GoogleMap.OnCameraIdleListener
com.google.android.gms.maps.GoogleMap.OnMarkerClickListener
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceClusterManager.OnClusterClickListenerCalled when a Cluster is clicked.
public interfaceClusterManager.OnClusterInfoWindowClickListenerCalled when a Cluster's Info Window is clicked.
public interfaceClusterManager.OnClusterInfoWindowLongClickListenerCalled when a Cluster's Info Window is long clicked.
public interfaceClusterManager.OnClusterItemClickListenerCalled when an individual ClusterItem is clicked.
public interfaceClusterManager.OnClusterItemInfoWindowClickListenerCalled when an individual ClusterItem's Info Window is clicked.
public interfaceClusterManager.OnClusterItemInfoWindowLongClickListenerCalled when an individual ClusterItem's Info Window is long clicked.
-
Field Summary
Fields Modifier and Type Field Description private final MarkerManager.CollectionmarkerCollectionprivate final MarkerManager.CollectionclusterMarkerCollectionprivate ClusterRenderer<T>rendererprivate Algorithm<T>algorithmprivate final MarkerManagermarkerManager
-
Constructor Summary
Constructors Constructor Description ClusterManager(Context context, GoogleMap mMap, MarkerManager markerManager)ClusterManager(Context context, GoogleMap mMap)
-
Method Summary
Modifier and Type Method Description final MarkerManager.CollectiongetMarkerCollection()final MarkerManager.CollectiongetClusterMarkerCollection()ClusterRenderer<T>getRenderer()UnitsetRenderer(ClusterRenderer<T> renderer)Algorithm<T>getAlgorithm()UnitsetAlgorithm(Algorithm<T> algorithm)final MarkerManagergetMarkerManager()UnitsetAlgorithm(ScreenBasedAlgorithm<T> algorithm)UnitsetAnimation(Boolean animate)UnitclearItems()Removes all items from the cluster manager. BooleanaddItems(Collection<T> items)Adds items to clusters. BooleanaddItem(T myItem)Adds an item to a cluster. Unitdiff(Collection<T> add, Collection<T> remove, Collection<T> modify)BooleanremoveItems(Collection<T> items)Removes items from clusters. BooleanremoveItem(T item)Removes an item from clusters. BooleanupdateItem(T item)Updates an item in clusters. Unitcluster()Force a re-cluster on the map. UnitonCameraIdle()Might re-cluster. BooleanonMarkerClick(Marker marker)UnitonInfoWindowClick(Marker marker)UnitsetOnClusterClickListener(ClusterManager.OnClusterClickListener<T> listener)Sets a callback that's invoked when a Cluster is tapped. UnitsetOnClusterInfoWindowClickListener(ClusterManager.OnClusterInfoWindowClickListener<T> listener)Sets a callback that's invoked when a Cluster info window is tapped. UnitsetOnClusterInfoWindowLongClickListener(ClusterManager.OnClusterInfoWindowLongClickListener<T> listener)Sets a callback that's invoked when a Cluster info window is long-pressed. UnitsetOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener)Sets a callback that's invoked when an individual ClusterItem is tapped. UnitsetOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener)Sets a callback that's invoked when an individual ClusterItem's Info Window is tapped. UnitsetOnClusterItemInfoWindowLongClickListener(ClusterManager.OnClusterItemInfoWindowLongClickListener<T> listener)Sets a callback that's invoked when an individual ClusterItem's Info Window is long-pressed. -
-
Method Detail
-
getMarkerCollection
final MarkerManager.Collection getMarkerCollection()
-
getClusterMarkerCollection
final MarkerManager.Collection getClusterMarkerCollection()
-
getRenderer
ClusterRenderer<T> getRenderer()
-
setRenderer
Unit setRenderer(ClusterRenderer<T> renderer)
-
getAlgorithm
Algorithm<T> getAlgorithm()
-
setAlgorithm
Unit setAlgorithm(Algorithm<T> algorithm)
-
getMarkerManager
final MarkerManager getMarkerManager()
-
setAlgorithm
Unit setAlgorithm(ScreenBasedAlgorithm<T> algorithm)
-
setAnimation
Unit setAnimation(Boolean animate)
-
clearItems
Unit clearItems()
Removes all items from the cluster manager. After calling this method you must invoke .cluster for the map to be cleared.
-
addItems
Boolean addItems(Collection<T> items)
Adds items to clusters. After calling this method you must invoke .cluster for the state of the clusters to be updated on the map.
- Parameters:
items- items to add to clusters- Returns:
true if the cluster manager contents changed as a result of the call
-
addItem
Boolean addItem(T myItem)
Adds an item to a cluster. After calling this method you must invoke .cluster for the state of the clusters to be updated on the map.
- Parameters:
myItem- item to add to clusters- Returns:
true if the cluster manager contents changed as a result of the call
-
diff
Unit diff(Collection<T> add, Collection<T> remove, Collection<T> modify)
-
removeItems
Boolean removeItems(Collection<T> items)
Removes items from clusters. After calling this method you must invoke .cluster for the state of the clusters to be updated on the map.
- Parameters:
items- items to remove from clusters- Returns:
true if the cluster manager contents changed as a result of the call
-
removeItem
Boolean removeItem(T item)
Removes an item from clusters. After calling this method you must invoke .cluster for the state of the clusters to be updated on the map.
- Parameters:
item- item to remove from clusters- Returns:
true if the item was removed from the cluster manager as a result of this call
-
updateItem
Boolean updateItem(T item)
Updates an item in clusters. After calling this method you must invoke .cluster for the state of the clusters to be updated on the map.
- Parameters:
item- item to update in clusters- Returns:
true if the item was updated in the cluster manager, false if the item is not contained within the cluster manager and the cluster manager contents are unchanged
-
cluster
Unit cluster()
Force a re-cluster on the map. You should call this after adding, removing, updating, or clearing item(s).
-
onCameraIdle
Unit onCameraIdle()
Might re-cluster.
-
onMarkerClick
Boolean onMarkerClick(Marker marker)
-
onInfoWindowClick
Unit onInfoWindowClick(Marker marker)
-
setOnClusterClickListener
Unit setOnClusterClickListener(ClusterManager.OnClusterClickListener<T> listener)
Sets a callback that's invoked when a Cluster is tapped. Note: For this listener to function, the ClusterManager must be added as a click listener to the map.
-
setOnClusterInfoWindowClickListener
Unit setOnClusterInfoWindowClickListener(ClusterManager.OnClusterInfoWindowClickListener<T> listener)
Sets a callback that's invoked when a Cluster info window is tapped. Note: For this listener to function, the ClusterManager must be added as a info window click listener to the map.
-
setOnClusterInfoWindowLongClickListener
Unit setOnClusterInfoWindowLongClickListener(ClusterManager.OnClusterInfoWindowLongClickListener<T> listener)
Sets a callback that's invoked when a Cluster info window is long-pressed. Note: For this listener to function, the ClusterManager must be added as a info window click listener to the map.
-
setOnClusterItemClickListener
Unit setOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener)
Sets a callback that's invoked when an individual ClusterItem is tapped. Note: For this listener to function, the ClusterManager must be added as a click listener to the map.
-
setOnClusterItemInfoWindowClickListener
Unit setOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener)
Sets a callback that's invoked when an individual ClusterItem's Info Window is tapped. Note: For this listener to function, the ClusterManager must be added as a info window click listener to the map.
-
setOnClusterItemInfoWindowLongClickListener
Unit setOnClusterItemInfoWindowLongClickListener(ClusterManager.OnClusterItemInfoWindowLongClickListener<T> listener)
Sets a callback that's invoked when an individual ClusterItem's Info Window is long-pressed. Note: For this listener to function, the ClusterManager must be added as a info window click listener to the map.
-
-
-
-