-
- 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.OnInfoWindowClickListener
Groups 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 interface
ClusterManager.OnClusterClickListener
Called when a Cluster is clicked.
public interface
ClusterManager.OnClusterInfoWindowClickListener
Called when a Cluster's Info Window is clicked.
public interface
ClusterManager.OnClusterInfoWindowLongClickListener
Called when a Cluster's Info Window is long clicked.
public interface
ClusterManager.OnClusterItemClickListener
Called when an individual ClusterItem is clicked.
public interface
ClusterManager.OnClusterItemInfoWindowClickListener
Called when an individual ClusterItem's Info Window is clicked.
public interface
ClusterManager.OnClusterItemInfoWindowLongClickListener
Called when an individual ClusterItem's Info Window is long clicked.
-
Constructor Summary
Constructors Constructor Description ClusterManager(Context context, GoogleMap map)
ClusterManager(Context context, GoogleMap map, MarkerManager markerManager)
-
Method Summary
Modifier and Type Method Description MarkerManager.Collection
getMarkerCollection()
MarkerManager.Collection
getClusterMarkerCollection()
MarkerManager
getMarkerManager()
void
setRenderer(ClusterRenderer<T> renderer)
void
setAlgorithm(Algorithm<T> algorithm)
void
setAlgorithm(ScreenBasedAlgorithm<T> algorithm)
void
setAnimation(boolean animate)
ClusterRenderer<T>
getRenderer()
Algorithm<T>
getAlgorithm()
void
clearItems()
Removes all items from the cluster manager. boolean
addItems(Collection<T> items)
Adds items to clusters. boolean
addItem(T myItem)
Adds an item to a cluster. void
diff(@Nullable() Collection<T> add, @Nullable() Collection<T> remove, @Nullable() Collection<T> modify)
boolean
removeItems(Collection<T> items)
Removes items from clusters. boolean
removeItem(T item)
Removes an item from clusters. boolean
updateItem(T item)
Updates an item in clusters. void
cluster()
Force a re-cluster on the map. void
onCameraIdle()
Might re-cluster. boolean
onMarkerClick(@NonNull() Marker marker)
void
onInfoWindowClick(@NonNull() Marker marker)
void
setOnClusterClickListener(ClusterManager.OnClusterClickListener<T> listener)
Sets a callback that's invoked when a Cluster is tapped. void
setOnClusterInfoWindowClickListener(ClusterManager.OnClusterInfoWindowClickListener<T> listener)
Sets a callback that's invoked when a Cluster info window is tapped. void
setOnClusterInfoWindowLongClickListener(ClusterManager.OnClusterInfoWindowLongClickListener<T> listener)
Sets a callback that's invoked when a Cluster info window is long-pressed. void
setOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener)
Sets a callback that's invoked when an individual ClusterItem is tapped. void
setOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener)
Sets a callback that's invoked when an individual ClusterItem's Info Window is tapped. void
setOnClusterItemInfoWindowLongClickListener(ClusterManager.OnClusterItemInfoWindowLongClickListener<T> listener)
Sets a callback that's invoked when an individual ClusterItem's Info Window is long-pressed. -
Methods inherited from class com.google.android.gms.maps.GoogleMap.OnCameraIdleListener
onCameraIdle
-
Methods inherited from class com.google.android.gms.maps.GoogleMap.OnMarkerClickListener
onMarkerClick
-
Methods inherited from class com.google.android.gms.maps.GoogleMap.OnInfoWindowClickListener
onInfoWindowClick
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ClusterManager
ClusterManager(Context context, GoogleMap map)
-
ClusterManager
ClusterManager(Context context, GoogleMap map, MarkerManager markerManager)
-
-
Method Detail
-
getMarkerCollection
MarkerManager.Collection getMarkerCollection()
-
getClusterMarkerCollection
MarkerManager.Collection getClusterMarkerCollection()
-
getMarkerManager
MarkerManager getMarkerManager()
-
setRenderer
void setRenderer(ClusterRenderer<T> renderer)
-
setAlgorithm
void setAlgorithm(Algorithm<T> algorithm)
-
setAlgorithm
void setAlgorithm(ScreenBasedAlgorithm<T> algorithm)
-
setAnimation
void setAnimation(boolean animate)
-
getRenderer
ClusterRenderer<T> getRenderer()
-
getAlgorithm
Algorithm<T> getAlgorithm()
-
clearItems
void 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 thestate of the clusters to be updated on the map.
- Parameters:
items
- items to add to clusters
-
addItem
boolean addItem(T myItem)
Adds an item to a cluster. After calling this method you must invoke cluster forthe state of the clusters to be updated on the map.
- Parameters:
myItem
- item to add to clusters
-
diff
void diff(@Nullable() Collection<T> add, @Nullable() Collection<T> remove, @Nullable() Collection<T> modify)
-
removeItems
boolean removeItems(Collection<T> items)
Removes items from clusters. After calling this method you must invoke cluster forthe state of the clusters to be updated on the map.
- Parameters:
items
- items to remove from clusters
-
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
-
updateItem
boolean updateItem(T item)
Updates an item in clusters. After calling this method you must invoke cluster forthe state of the clusters to be updated on the map.
- Parameters:
item
- item to update in clusters
-
cluster
void cluster()
Force a re-cluster on the map. You should call this after adding, removing, updating,or clearing item(s).
-
onCameraIdle
void onCameraIdle()
Might re-cluster.
-
onMarkerClick
boolean onMarkerClick(@NonNull() Marker marker)
-
onInfoWindowClick
void onInfoWindowClick(@NonNull() Marker marker)
-
setOnClusterClickListener
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
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
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
void setOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener)
Sets a callback that's invoked when an individual ClusterItem is tapped. Note: For thislistener to function, the ClusterManager must be added as a click listener to the map.
-
setOnClusterItemInfoWindowClickListener
void setOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener)
Sets a callback that's invoked when an individual ClusterItem's Info Window is tapped. Note: For thislistener to function, the ClusterManager must be added as a info window click listener to the map.
-
setOnClusterItemInfoWindowLongClickListener
void setOnClusterItemInfoWindowLongClickListener(ClusterManager.OnClusterItemInfoWindowLongClickListener<T> listener)
Sets a callback that's invoked when an individual ClusterItem's Info Window is long-pressed. Note: For thislistener to function, the ClusterManager must be added as a info window click listener to the map.
-
-
-
-