Class DefaultClusterRenderer<T extends ClusterItem>
- java.lang.Object
-
- com.google.maps.android.clustering.view.DefaultClusterRenderer<T>
-
- All Implemented Interfaces:
ClusterRenderer<T>
public class DefaultClusterRenderer<T extends ClusterItem> extends java.lang.Object implements ClusterRenderer<T>
The default view for a ClusterManager. Markers are animated in and out of clusters.
-
-
Constructor Summary
Constructors Constructor Description DefaultClusterRenderer(android.content.Context context, com.google.android.gms.maps.GoogleMap map, ClusterManager<T> clusterManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Cluster<T>
getCluster(com.google.android.gms.maps.model.Marker marker)
Get the Cluster from a markerT
getClusterItem(com.google.android.gms.maps.model.Marker marker)
Get the ClusterItem from a markerint
getClusterTextAppearance(int clusterSize)
Called to determine the text appearance of a cluster.int
getColor(int clusterSize)
Called to determine the color of a Cluster.com.google.android.gms.maps.model.Marker
getMarker(Cluster<T> cluster)
Get the marker from a Clustercom.google.android.gms.maps.model.Marker
getMarker(T clusterItem)
Get the marker from a ClusterItemint
getMinClusterSize()
Gets the minimum cluster size used to render clusters.void
onAdd()
Called when the view is added.void
onClustersChanged(java.util.Set<? extends Cluster<T>> clusters)
Called when the view needs to be updated because new clusters need to be displayed.void
onRemove()
Called when the view is removed.void
setAnimation(boolean animate)
Called to set animation on or offvoid
setAnimationDuration(long animationDurationMs)
Sets the length of the animation in milliseconds.void
setMinClusterSize(int minClusterSize)
Sets the minimum cluster size used to render clusters.void
setOnClusterClickListener(ClusterManager.OnClusterClickListener<T> listener)
void
setOnClusterInfoWindowClickListener(ClusterManager.OnClusterInfoWindowClickListener<T> listener)
void
setOnClusterInfoWindowLongClickListener(ClusterManager.OnClusterInfoWindowLongClickListener<T> listener)
void
setOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener)
void
setOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener)
void
setOnClusterItemInfoWindowLongClickListener(ClusterManager.OnClusterItemInfoWindowLongClickListener<T> listener)
-
-
-
Constructor Detail
-
DefaultClusterRenderer
public DefaultClusterRenderer(android.content.Context context, com.google.android.gms.maps.GoogleMap map, ClusterManager<T> clusterManager)
-
-
Method Detail
-
onAdd
public void onAdd()
Description copied from interface:ClusterRenderer
Called when the view is added.- Specified by:
onAdd
in interfaceClusterRenderer<T extends ClusterItem>
-
onRemove
public void onRemove()
Description copied from interface:ClusterRenderer
Called when the view is removed.- Specified by:
onRemove
in interfaceClusterRenderer<T extends ClusterItem>
-
getColor
public int getColor(int clusterSize)
Description copied from interface:ClusterRenderer
Called to determine the color of a Cluster.- Specified by:
getColor
in interfaceClusterRenderer<T extends ClusterItem>
-
getClusterTextAppearance
@StyleRes public int getClusterTextAppearance(int clusterSize)
Description copied from interface:ClusterRenderer
Called to determine the text appearance of a cluster.- Specified by:
getClusterTextAppearance
in interfaceClusterRenderer<T extends ClusterItem>
-
getMinClusterSize
public int getMinClusterSize()
Gets the minimum cluster size used to render clusters. For example, if "4" is returned, then for any clusters of size 3 or less the items will be rendered as individual markers instead of as a single cluster marker.- Returns:
- the minimum cluster size used to render clusters. For example, if "4" is returned, then for any clusters of size 3 or less the items will be rendered as individual markers instead of as a single cluster marker.
-
setMinClusterSize
public void setMinClusterSize(int minClusterSize)
Sets the minimum cluster size used to render clusters. For example, if "4" is provided, then for any clusters of size 3 or less the items will be rendered as individual markers instead of as a single cluster marker.- Parameters:
minClusterSize
- the minimum cluster size used to render clusters. For example, if "4" is provided, then for any clusters of size 3 or less the items will be rendered as individual markers instead of as a single cluster marker.
-
onClustersChanged
public void onClustersChanged(java.util.Set<? extends Cluster<T>> clusters)
Description copied from interface:ClusterRenderer
Called when the view needs to be updated because new clusters need to be displayed.- Specified by:
onClustersChanged
in interfaceClusterRenderer<T extends ClusterItem>
- Parameters:
clusters
- the clusters to be displayed.
-
setOnClusterClickListener
public void setOnClusterClickListener(ClusterManager.OnClusterClickListener<T> listener)
- Specified by:
setOnClusterClickListener
in interfaceClusterRenderer<T extends ClusterItem>
-
setOnClusterInfoWindowClickListener
public void setOnClusterInfoWindowClickListener(ClusterManager.OnClusterInfoWindowClickListener<T> listener)
- Specified by:
setOnClusterInfoWindowClickListener
in interfaceClusterRenderer<T extends ClusterItem>
-
setOnClusterInfoWindowLongClickListener
public void setOnClusterInfoWindowLongClickListener(ClusterManager.OnClusterInfoWindowLongClickListener<T> listener)
- Specified by:
setOnClusterInfoWindowLongClickListener
in interfaceClusterRenderer<T extends ClusterItem>
-
setOnClusterItemClickListener
public void setOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener)
- Specified by:
setOnClusterItemClickListener
in interfaceClusterRenderer<T extends ClusterItem>
-
setOnClusterItemInfoWindowClickListener
public void setOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener)
- Specified by:
setOnClusterItemInfoWindowClickListener
in interfaceClusterRenderer<T extends ClusterItem>
-
setOnClusterItemInfoWindowLongClickListener
public void setOnClusterItemInfoWindowLongClickListener(ClusterManager.OnClusterItemInfoWindowLongClickListener<T> listener)
- Specified by:
setOnClusterItemInfoWindowLongClickListener
in interfaceClusterRenderer<T extends ClusterItem>
-
setAnimation
public void setAnimation(boolean animate)
Description copied from interface:ClusterRenderer
Called to set animation on or off- Specified by:
setAnimation
in interfaceClusterRenderer<T extends ClusterItem>
-
setAnimationDuration
public void setAnimationDuration(long animationDurationMs)
Sets the length of the animation in milliseconds. The default duration is 300 milliseconds.- Specified by:
setAnimationDuration
in interfaceClusterRenderer<T extends ClusterItem>
- Parameters:
animationDurationMs
- long: The length of the animation, in milliseconds. This value cannot be negative.
-
getMarker
public com.google.android.gms.maps.model.Marker getMarker(T clusterItem)
Get the marker from a ClusterItem- Parameters:
clusterItem
- ClusterItem which you will obtain its marker- Returns:
- a marker from a ClusterItem or null if it does not exists
-
getClusterItem
public T getClusterItem(com.google.android.gms.maps.model.Marker marker)
Get the ClusterItem from a marker- Parameters:
marker
- which you will obtain its ClusterItem- Returns:
- a ClusterItem from a marker or null if it does not exists
-
getMarker
public com.google.android.gms.maps.model.Marker getMarker(Cluster<T> cluster)
Get the marker from a Cluster- Parameters:
cluster
- which you will obtain its marker- Returns:
- a marker from a cluster or null if it does not exists
-
-