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 markerTgetClusterItem(com.google.android.gms.maps.model.Marker marker)Get the ClusterItem from a markerintgetClusterTextAppearance(int clusterSize)Called to determine the text appearance of a cluster.intgetColor(int clusterSize)Called to determine the color of a Cluster.com.google.android.gms.maps.model.MarkergetMarker(Cluster<T> cluster)Get the marker from a Clustercom.google.android.gms.maps.model.MarkergetMarker(T clusterItem)Get the marker from a ClusterItemintgetMinClusterSize()Gets the minimum cluster size used to render clusters.voidonAdd()Called when the view is added.voidonClustersChanged(java.util.Set<? extends Cluster<T>> clusters)Called when the view needs to be updated because new clusters need to be displayed.voidonRemove()Called when the view is removed.voidsetAnimation(boolean animate)Called to set animation on or offvoidsetAnimationDuration(long animationDurationMs)Sets the length of the animation in milliseconds.voidsetMinClusterSize(int minClusterSize)Sets the minimum cluster size used to render clusters.voidsetOnClusterClickListener(ClusterManager.OnClusterClickListener<T> listener)voidsetOnClusterInfoWindowClickListener(ClusterManager.OnClusterInfoWindowClickListener<T> listener)voidsetOnClusterInfoWindowLongClickListener(ClusterManager.OnClusterInfoWindowLongClickListener<T> listener)voidsetOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener)voidsetOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener)voidsetOnClusterItemInfoWindowLongClickListener(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:ClusterRendererCalled when the view is added.- Specified by:
onAddin interfaceClusterRenderer<T extends ClusterItem>
-
onRemove
public void onRemove()
Description copied from interface:ClusterRendererCalled when the view is removed.- Specified by:
onRemovein interfaceClusterRenderer<T extends ClusterItem>
-
getColor
public int getColor(int clusterSize)
Description copied from interface:ClusterRendererCalled to determine the color of a Cluster.- Specified by:
getColorin interfaceClusterRenderer<T extends ClusterItem>
-
getClusterTextAppearance
@StyleRes public int getClusterTextAppearance(int clusterSize)
Description copied from interface:ClusterRendererCalled to determine the text appearance of a cluster.- Specified by:
getClusterTextAppearancein 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:ClusterRendererCalled when the view needs to be updated because new clusters need to be displayed.- Specified by:
onClustersChangedin interfaceClusterRenderer<T extends ClusterItem>- Parameters:
clusters- the clusters to be displayed.
-
setOnClusterClickListener
public void setOnClusterClickListener(ClusterManager.OnClusterClickListener<T> listener)
- Specified by:
setOnClusterClickListenerin interfaceClusterRenderer<T extends ClusterItem>
-
setOnClusterInfoWindowClickListener
public void setOnClusterInfoWindowClickListener(ClusterManager.OnClusterInfoWindowClickListener<T> listener)
- Specified by:
setOnClusterInfoWindowClickListenerin interfaceClusterRenderer<T extends ClusterItem>
-
setOnClusterInfoWindowLongClickListener
public void setOnClusterInfoWindowLongClickListener(ClusterManager.OnClusterInfoWindowLongClickListener<T> listener)
- Specified by:
setOnClusterInfoWindowLongClickListenerin interfaceClusterRenderer<T extends ClusterItem>
-
setOnClusterItemClickListener
public void setOnClusterItemClickListener(ClusterManager.OnClusterItemClickListener<T> listener)
- Specified by:
setOnClusterItemClickListenerin interfaceClusterRenderer<T extends ClusterItem>
-
setOnClusterItemInfoWindowClickListener
public void setOnClusterItemInfoWindowClickListener(ClusterManager.OnClusterItemInfoWindowClickListener<T> listener)
- Specified by:
setOnClusterItemInfoWindowClickListenerin interfaceClusterRenderer<T extends ClusterItem>
-
setOnClusterItemInfoWindowLongClickListener
public void setOnClusterItemInfoWindowLongClickListener(ClusterManager.OnClusterItemInfoWindowLongClickListener<T> listener)
- Specified by:
setOnClusterItemInfoWindowLongClickListenerin interfaceClusterRenderer<T extends ClusterItem>
-
setAnimation
public void setAnimation(boolean animate)
Description copied from interface:ClusterRendererCalled to set animation on or off- Specified by:
setAnimationin 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:
setAnimationDurationin 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
-
-