clusterProperty

fun clusterProperty(propertyName: String, operatorExpr: Expression, mapExpr: Expression): GeoJsonSource.Builder

An object defining custom properties on the generated clusters if clustering is enabled, aggregating values from clustered points. Has the form {"property_name": [operator, map_expression]}. operator is any expression function that accepts at least 2 operands (e.g. "+" or "max") — it accumulates the property value from clusters/points the cluster contains; map_expression produces the value of a single point.

Example: {"sum": ["+", ["get", "scalerank"]]}.

For more advanced use cases, in place of operator, you can use a custom reduce expression that references a special ["accumulated"] value, e.g.: {"sum": [["+", ["accumulated"], ["get", "sum"]], ["get", "scalerank"]]}

Parameters

propertyName

name of the property

operatorExpr

operatorExpr is any expression function that accepts at least 2 operands (e.g. "+" or "max"). It accumulates the property value from clusters/points the cluster contains. It can either be a literal with single operator, or be a valid expression

mapExpr

map expression produces the value of a single point, it shall be a valid expression

fun clusterProperty(propertyName: String, mapExpr: Expression): GeoJsonSource.Builder

An object defining custom properties on the generated clusters if clustering is enabled, aggregating values from clustered points. Has the form {"property_name": [operator, map_expression]}. operator is any expression function that accepts at least 2 operands (e.g. "+" or "max") — it accumulates the property value from clusters/points the cluster contains; map_expression produces the value of a single point.

Example: {"sum": ["+", ["get", "scalerank"]]}.

For more advanced use cases, in place of operator, you can use a custom reduce expression that references a special ["accumulated"] value, e.g.: {"sum": [["+", ["accumulated"], ["get", "sum"]], ["get", "scalerank"]]}

Parameters

propertyName

name of the property

mapExpr

map expression produces the value of a single point, it shall be a valid expression