summaryrefslogtreecommitdiff
path: root/platform/macos/docs/guides/For Style Authors.md
diff options
context:
space:
mode:
Diffstat (limited to 'platform/macos/docs/guides/For Style Authors.md')
-rw-r--r--platform/macos/docs/guides/For Style Authors.md122
1 files changed, 80 insertions, 42 deletions
diff --git a/platform/macos/docs/guides/For Style Authors.md b/platform/macos/docs/guides/For Style Authors.md
index 9eeb159b75..4a16066a2a 100644
--- a/platform/macos/docs/guides/For Style Authors.md
+++ b/platform/macos/docs/guides/For Style Authors.md
@@ -257,12 +257,16 @@ In style JSON | In Objective-C | In Swift
## Setting attribute values
Each property representing a layout or paint attribute is set to an
-`MGLStyleValue` object, which is either an `MGLConstantStyleValue` object (for
-constant values) or an `MGLStyleFunction` object (for style functions). The
-style value object is a container for the raw value or function parameters that
-you want the attribute to be set to.
+`NSExpression` object. `NSExpression` objects play the same role as
+[expressions in the Mapbox Style Specification](https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions),
+but you create the former using a very different syntax. `NSExpression`’s format
+string syntax is reminiscent of a spreadsheet formula or an expression in a
+database query. See the
+“[Predicates and Expressions](Predicates and Expressions.md)” guide for an
+overview of the expression support in this SDK. This SDK no longer supports
+style functions; use expressions instead.
-### Constant style values
+### Constant values in expressions
In contrast to the JSON type that the style specification defines for each
layout or paint property, the style value object often contains a more specific
@@ -273,10 +277,10 @@ or set.
In style JSON | In Objective-C | In Swift
--------------|-----------------------|---------
Color | `NSColor` | `NSColor`
-Enum | `NSValue` (see `NSValue(MGLAdditions)`) | `NSValue` (see `NSValue(MGLAdditions)`)
+Enum | `NSString` | `String`
String | `NSString` | `String`
-Boolean | `NSNumber.boolValue` | `Bool`
-Number | `NSNumber.floatValue` | `Float`
+Boolean | `NSNumber.boolValue` | `NSNumber.boolValue`
+Number | `NSNumber.floatValue` | `NSNumber.floatValue`
Array (`-dasharray`) | `NSArray<NSNumber>` | `[Float]`
Array (`-font`) | `NSArray<NSString>` | `[String]`
Array (`-offset`, `-translate`) | `NSValue` containing `CGVector` | `NSValue` containing `CGVector`
@@ -294,38 +298,72 @@ offset or translation upward, while a negative `CGVector.dy` means an offset or
translation downward. This is the reverse of how `CGVector` is interpreted on
iOS.
-### Style functions
-
-A _style function_ allows you to vary the value of a layout or paint attribute
-based on the zoom level, data provided by content sources, or both. For more
-information about style functions, see “[Using Style Functions at Runtime](using-style-functions-at-runtime.html)”.
-
-Each kind of style function is represented by a distinct class, but you
-typically create style functions as you create any other style value, using
-class methods on `MGLStyleValue`:
-
-In style specification | SDK class | SDK factory method
----------------------------|-----------------------------|-------------------
-zoom function | `MGLCameraStyleFunction` | `+[MGLStyleValue valueWithInterpolationMode:cameraStops:options:]`
-property function | `MGLSourceStyleFunction` | `+[MGLStyleValue valueWithInterpolationMode:sourceStops:attributeName:options:]`
-zoom-and-property function | `MGLCompositeStyleFunction` | `+[MGLStyleValue valueWithInterpolationMode:compositeStops:attributeName:options:]`
-
-The documentation for each individual style layer property indicates the kinds
-of style functions that are enabled for that property.
-
-When you create a style function, you specify an _interpolation mode_ and a
-series of _stops_. Each stop determines the effective value displayed at a
-particular zoom level (for camera functions) or the effective value on features
-with a particular attribute value in the content source (for source functions).
-The interpolation mode tells the SDK how to calculate the effective value
-between any two stops:
-
-In style specification | In the SDK
------------------------------|-----------
-`exponential` | `MGLInterpolationModeExponential`
-`interval` | `MGLInterpolationModeInterval`
-`categorical` | `MGLInterpolationModeCategorical`
-`identity` | `MGLInterpolationModeIdentity`
+### Expression operators
+
+In style specification | Method, function, or predicate type | Format string syntax
+-----------------------|-------------------------------------|---------------------
+`array` | |
+`boolean` | |
+`literal` | `+[NSExpression expressionForConstantValue:]` | `%@` representing `NSArray` or `NSDictionary`
+`number` | |
+`string` | |
+`to-boolean` | `boolValue` |
+`to-color` | |
+`to-number` | `mgl_numberWithFallbackValues:` |
+`to-string` | `stringValue` |
+`typeof` | |
+`geometry-type` | |
+`id` | |
+`properties` | |
+`at` | |
+`get` | `+[NSExpression expressionForKeyPath:]` | Key path
+`has` | |
+`length` | `count:` | `count({1, 2, 2, 3, 4, 7, 9})`
+`!` | `NSNotPredicateType` | `NOT (p0 OR … OR pn)`
+`!=` | `NSNotEqualToPredicateOperatorType` | `key != value`
+`<` | `NSLessThanPredicateOperatorType` | `key < value`
+`<=` | `NSLessThanOrEqualToPredicateOperatorType` | `key <= value`
+`==` | `NSEqualToPredicateOperatorType` | `key == value`
+`>` | `NSGreaterThanPredicateOperatorType` | `key > value`
+`>=` | `NSGreaterThanOrEqualToPredicateOperatorType` | `key >= value`
+`all` | `NSAndPredicateType` | `p0 AND … AND pn`
+`any` | `NSOrPredicateType` | `p0 OR … OR pn`
+`case` | `+[NSExpression expressionForConditional:trueExpression:falseExpression:]` | `TERNARY(condition, trueExpression, falseExpression)`
+`coalesce` | |
+`match` | |
+`interpolate` | `mgl_interpolateWithCurveType:parameters:stops:` |
+`step` | `mgl_stepWithMinimum:stops:` |
+`let` | `mgl_expressionWithContext:` |
+`var` | `+[NSExpression expressionForVariable:]` | `$variable`
+`concat` | `stringByAppendingString:` |
+`downcase` | `lowercase:` | `lowercase('DOWNTOWN')`
+`upcase` | `uppercase:` | `uppercase('Elysian Fields')`
+`rgb` | `+[NSColor colorWithCalibratedRed:green:blue:alpha:]` |
+`rgba` | `+[NSColor colorWithCalibratedRed:green:blue:alpha:]` |
+`to-rgba` | |
+`-` | `from:subtract:` | `2 - 1`
+`*` | `multiply:by:` | `1 * 2`
+`/` | `divide:by:` | `1 / 2`
+`%` | `modulus:by:` |
+`^` | `raise:toPower:` | `2 ** 2`
+`+` | `add:to:` | `1 + 2`
+`acos` | |
+`asin` | |
+`atan` | |
+`cos` | |
+`e` | | `%@` representing `NSNumber` containing `M_E`
+`ln` | `ln:` | `ln(2)`
+`ln2` | | `%@` representing `NSNumber` containing `M_LN2`
+`log10` | `log:` | `log(1)`
+`log2` | |
+`max` | `max:` | `max({1, 2, 2, 3, 4, 7, 9})`
+`min` | `min:` | `min({1, 2, 2, 3, 4, 7, 9})`
+`pi` | | `%@` representing `NSNumber` containing `M_PI`
+`sin` | |
+`sqrt` | `sqrt:` | `sqrt(2)`
+`tan` | |
+`zoom` | | `$zoom`
+`heatmap-density` | | `$heatmapDensity`
## Filtering sources
@@ -350,5 +388,5 @@ In style JSON | In the format string
`["any", f0, …, fn]` | `p0 OR … OR pn`
`["none", f0, …, fn]` | `NOT (p0 OR … OR pn)`
-See the `MGLVectorStyleLayer.predicate` documentation for a full description of
-the supported operators and operand types.
+See the “[Predicates and Expressions](Predicates and Expressions.md)” guide for
+a full description of the supported operators and operand types.