Class ClusterManager<T extends ClusterItem>
- java.lang.Object
-
- com.google.maps.android.clustering.ClusterManager<T>
-
- 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> extends java.lang.Object implements com.google.android.gms.maps.GoogleMap.OnCameraIdleListener, com.google.android.gms.maps.GoogleMap.OnMarkerClickListener, com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListenerGroups many items on a map based on zoom level.ClusterManager should be added to the map as an:
GoogleMap.OnCameraIdleListenerGoogleMap.OnMarkerClickListener
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceClusterManager.OnClusterClickListener<T extends ClusterItem>Called when a Cluster is clicked.static interfaceClusterManager.OnClusterInfoWindowClickListener<T extends ClusterItem>Called when a Cluster's Info Window is clicked.static interfaceClusterManager.OnClusterInfoWindowLongClickListener<T extends ClusterItem>Called when a Cluster's Info Window is long clicked.static interfaceClusterManager.OnClusterItemClickListener<T extends ClusterItem>Called when an individual ClusterItem is clicked.static interfaceClusterManager.OnClusterItemInfoWindowClickListener<T extends ClusterItem>Called when an individual ClusterItem's Info Window is clicked.static interfaceClusterManager.OnClusterItemInfoWindowLongClickListener<T extends ClusterItem>Called when an individual ClusterItem's Info Window is long clicked.
-
Constructor Summary
Constructors Constructor Description ClusterManager(android.content.Context context, com.google.android.gms.maps.GoogleMap map)ClusterManager(android.content.Context context, com.google.android.gms.maps.GoogleMap map, MarkerManager markerManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddItem(T myItem)Adds an item to a cluster.booleanaddItems(java.util.Collection<T> items)Adds items to clusters.voidclearItems()Removes all items from the cluster manager.voidcluster()Force a re-cluster on the map.Algorithm<T>getAlgorithm()MarkerManager.CollectiongetClusterMarkerCollection()MarkerManager.CollectiongetMarkerCollection()MarkerManagergetMarkerManager()ClusterRenderer<T>getRenderer()voidonCameraIdle()Might re-cluster.voidonInfoWindowClick(com.google.android.gms.maps.model.Marker marker)booleanonMarkerClick(com.google.android.gms.maps.model.Marker marker)booleanremoveItem(T item)Removes an item from clusters.booleanremoveItems(java.util.Collection<T> items)Removes items from clusters.voidsetAlgorithm(Algorithm<T> algorithm)voidsetAlgorithm(ScreenBasedAlgorithm<T> algorithm)voidsetAnimation(boolean animate)voidsetOnClusterClickListener(ClusterManager.OnClusterClickListener<T> listener)Sets a callback that's invoked when a Cluster is tapped.voidsetOnClusterInfoWindowClickListener(ClusterManager.OnClusterInfoWindowClickListener<T> listener)Sets a callback that's invoked when a Cluster info window is tapped.voidsetOnClusterInfoWindowLongClickListener(ClusterManager.OnClusterInfoWindowLongClickListener<T> listener)Sets a callback that's invoked when a Cluster info window is long-pressed.voidsetOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener)Sets a callback that's invoked when an individual ClusterItem is tapped.voidsetOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener)Sets a callback that's invoked when an individual ClusterItem's Info Window is tapped.voidsetOnClusterItemInfoWindowLongClickListener(ClusterManager.OnClusterItemInfoWindowLongClickListener<T> listener)Sets a callback that's invoked when an individual ClusterItem's Info Window is long-pressed.voidsetRenderer(ClusterRenderer<T> renderer)booleanupdateItem(T item)Updates an item in clusters.
-
-
-
Constructor Detail
-
ClusterManager
public ClusterManager(android.content.Context context, com.google.android.gms.maps.GoogleMap map)
-
ClusterManager
public ClusterManager(android.content.Context context, com.google.android.gms.maps.GoogleMap map, MarkerManager markerManager)
-
-
Method Detail
-
getMarkerCollection
public MarkerManager.Collection getMarkerCollection()
-
getClusterMarkerCollection
public MarkerManager.Collection getClusterMarkerCollection()
-
getMarkerManager
public MarkerManager getMarkerManager()
-
setRenderer
public void setRenderer(ClusterRenderer<T> renderer)
-
setAlgorithm
public void setAlgorithm(ScreenBasedAlgorithm<T> algorithm)
-
setAnimation
public void setAnimation(boolean animate)
-
getRenderer
public ClusterRenderer<T> getRenderer()
-
clearItems
public void clearItems()
Removes all items from the cluster manager. After calling this method you must invokecluster()for the map to be cleared.
-
addItems
public boolean addItems(java.util.Collection<T> items)
Adds items to clusters. After calling this method you must invokecluster()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
public boolean addItem(T myItem)
Adds an item to a cluster. After calling this method you must invokecluster()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
-
removeItems
public boolean removeItems(java.util.Collection<T> items)
Removes items from clusters. After calling this method you must invokecluster()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
public boolean removeItem(T item)
Removes an item from clusters. After calling this method you must invokecluster()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
public boolean updateItem(T item)
Updates an item in clusters. After calling this method you must invokecluster()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
public void cluster()
Force a re-cluster on the map. You should call this after adding, removing, updating, or clearing item(s).
-
onCameraIdle
public void onCameraIdle()
Might re-cluster.- Specified by:
onCameraIdlein interfacecom.google.android.gms.maps.GoogleMap.OnCameraIdleListener
-
onMarkerClick
public boolean onMarkerClick(@NonNull com.google.android.gms.maps.model.Marker marker)- Specified by:
onMarkerClickin interfacecom.google.android.gms.maps.GoogleMap.OnMarkerClickListener
-
onInfoWindowClick
public void onInfoWindowClick(@NonNull com.google.android.gms.maps.model.Marker marker)- Specified by:
onInfoWindowClickin interfacecom.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener
-
setOnClusterClickListener
public void 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
public void 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
public void 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
public void 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
public void 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
public void 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.
-
-