summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLShapeSource.h
diff options
context:
space:
mode:
Diffstat (limited to 'platform/darwin/src/MGLShapeSource.h')
-rw-r--r--platform/darwin/src/MGLShapeSource.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/platform/darwin/src/MGLShapeSource.h b/platform/darwin/src/MGLShapeSource.h
index f11e45722b..73171dfe17 100644
--- a/platform/darwin/src/MGLShapeSource.h
+++ b/platform/darwin/src/MGLShapeSource.h
@@ -45,19 +45,27 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLShapeSourceOption MGLShapeSourceOptionClus
An `NSDictionary` object where the key is an `NSString`. The dictionary key will
be the feature attribute key. The resulting attribute value is
aggregated from the clustered points. The dictionary value is an `NSArray`
- consisting of two objects.
+ consisting of two `NSExpression` objects.
The first object determines how the attribute values are accumulated from the
- cluster points. The resulting value is assigned to the specified attribute key.
- You can use one of the following:
-
- * An `[NSExpression expressionForConstantValue:]` containing a single function string, such as `sum` or `max`, which takes at least two operands.
- * An `NSExpression` that takes two expression arguments: `featureAccumulated` and
- another valid expression.
+ cluster points. It is an `NSExpression` with an expression function that accepts
+ two or more arguments (such as `sum` or `max`). The arguments should be
+ `featureAccumulated` and the previously defined feature attribute key. The
+ resulting value is assigned to the specified attribute key.
The second `NSExpression` in the array determines which
attribute values are accessed from individual features within a cluster.
+ ```swift
+ let key = "sumValue"
+ let firstExpression = NSExpression(format: "sum({ $featureAccumulated, %@ })", key)
+ let secondExpression = NSExpression(forKeyPath: "magnitude")
+ let clusterPropertiesDictionary = [key : [firstExpression, secondExpression]]
+
+ let options : [MGLShapeSourceOption : Any] = [.clustered : true,
+ .clusterProperties: clusterPropertiesDictionary]
+ ```
+
This option corresponds to the
<a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson-clusterProperties"><code>clusterProperties</code></a>
source property in the Mapbox Style Specification.