Class ClusterOptions


  • public class ClusterOptions
    extends java.lang.Object
    Options to show and configure symbol clustering with using SymbolManager.

    It exposes a minimal of configuration options, a more advanced setup can be created manually with using CircleLayer and SymbolLayers directly.

    • Constructor Summary

      Constructors 
      Constructor Description
      ClusterOptions()
      Creates a default ClusterOptions object
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void apply​(com.mapbox.mapboxsdk.maps.Style style, java.lang.String sourceId)
      Apply cluster options to a style and source id.
      com.mapbox.mapboxsdk.style.expressions.Expression getCircleRadius()
      Get the circle radius of the cluster items, 18 by default
      int getClusterMaxZoom()
      Set the cluster maximum, 14 by default.
      int getClusterRadius()
      Get the cluster radius, 50 by default.
      androidx.core.util.Pair<java.lang.Integer,​java.lang.Integer>[] getColorLevels()
      Get the cluster color levels, which a pair constructed with amount of point and a int color value.
      com.mapbox.mapboxsdk.style.expressions.Expression getTextColor()
      Get the text color of cluster item.
      com.mapbox.mapboxsdk.style.expressions.Expression getTextField()
      Set the text field of a cluster item.
      com.mapbox.mapboxsdk.style.expressions.Expression getTextSize()
      Get the text size of cluster item.
      ClusterOptions withCircleRadius​(com.mapbox.mapboxsdk.style.expressions.Expression circleRadius)
      Set the circle radius of cluster items.
      ClusterOptions withClusterMaxZoom​(int clusterMaxZoom)
      Set the cluster maximum zoom, 14 by default.
      ClusterOptions withClusterRadius​(int clusterRadius)
      Set the cluster radius, 50 by default.
      ClusterOptions withColorLevels​(androidx.core.util.Pair<java.lang.Integer,​java.lang.Integer>[] colorLevels)
      Set the cluster color levels, which a pair constructed with amount of point and a int color value.
      ClusterOptions withTextColor​(com.mapbox.mapboxsdk.style.expressions.Expression textColor)
      Set the text color of cluster item.
      ClusterOptions withTextField​(com.mapbox.mapboxsdk.style.expressions.Expression textField)
      Set the text field of a cluster item.
      ClusterOptions withTextSize​(com.mapbox.mapboxsdk.style.expressions.Expression textSize)
      Set the text size of cluster item.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClusterOptions

        public ClusterOptions()
        Creates a default ClusterOptions object
    • Method Detail

      • getClusterRadius

        public int getClusterRadius()
        Get the cluster radius, 50 by default.
        Returns:
        the radius at which the cluster dissolves
      • withClusterRadius

        public ClusterOptions withClusterRadius​(int clusterRadius)
        Set the cluster radius, 50 by default.
        Parameters:
        clusterRadius - the radius at which the cluster dissolves
        Returns:
        this
      • getClusterMaxZoom

        public int getClusterMaxZoom()
        Set the cluster maximum, 14 by default.
        Returns:
        the cluster maximum zoom, at this zoom level clusters dissolve automatically
      • withClusterMaxZoom

        public ClusterOptions withClusterMaxZoom​(int clusterMaxZoom)
        Set the cluster maximum zoom, 14 by default.
        Parameters:
        clusterMaxZoom - the cluster maximum zoom, at this zoom level clusters dissolve automatically
        Returns:
        this
      • getColorLevels

        @NonNull
        public androidx.core.util.Pair<java.lang.Integer,​java.lang.Integer>[] getColorLevels()
        Get the cluster color levels, which a pair constructed with amount of point and a int color value.
        Returns:
        the cluster color levels array
      • withColorLevels

        public ClusterOptions withColorLevels​(@NonNull
                                              androidx.core.util.Pair<java.lang.Integer,​java.lang.Integer>[] colorLevels)
        Set the cluster color levels, which a pair constructed with amount of point and a int color value.
        Parameters:
        colorLevels - the cluster color levels array
        Returns:
        this
      • getCircleRadius

        @Nullable
        public com.mapbox.mapboxsdk.style.expressions.Expression getCircleRadius()
        Get the circle radius of the cluster items, 18 by default
        Returns:
        the cluster item circle radius
      • withCircleRadius

        public ClusterOptions withCircleRadius​(@Nullable
                                               com.mapbox.mapboxsdk.style.expressions.Expression circleRadius)
        Set the circle radius of cluster items. 18 by default
        Parameters:
        circleRadius - the cluster item circle radius
        Returns:
        this
      • getTextColor

        @Nullable
        public com.mapbox.mapboxsdk.style.expressions.Expression getTextColor()
        Get the text color of cluster item. White by default
        Returns:
        the cluster item text color
      • withTextColor

        public ClusterOptions withTextColor​(@Nullable
                                            com.mapbox.mapboxsdk.style.expressions.Expression textColor)
        Set the text color of cluster item. White by default.
        Parameters:
        textColor - the cluster item text color
        Returns:
        this
      • getTextSize

        @Nullable
        public com.mapbox.mapboxsdk.style.expressions.Expression getTextSize()
        Get the text size of cluster item. 12 by default.
        Returns:
        the cluster item text size
      • withTextSize

        public ClusterOptions withTextSize​(@Nullable
                                           com.mapbox.mapboxsdk.style.expressions.Expression textSize)
        Set the text size of cluster item. 12 by default.
        Parameters:
        textSize - the cluster item text size
        Returns:
        this
      • getTextField

        @Nullable
        public com.mapbox.mapboxsdk.style.expressions.Expression getTextField()
        Set the text field of a cluster item. toNumber(get("point_count")) by default.
        Returns:
        the cluster item text field
      • withTextField

        public ClusterOptions withTextField​(@Nullable
                                            com.mapbox.mapboxsdk.style.expressions.Expression textField)
        Set the text field of a cluster item. toNumber(get("point_count")) by default.
        Parameters:
        textField - the cluster item text field
        Returns:
        this
      • apply

        public void apply​(@NonNull
                          com.mapbox.mapboxsdk.maps.Style style,
                          @NonNull
                          java.lang.String sourceId)
        Apply cluster options to a style and source id.
        Parameters:
        style - style to apply this to
        sourceId - source id to apply this to