Literal Style / add support for variables in the style

These variables are accessed using the `var` operator, and are meant
to be mutated directly in the style object. When doing so,
the new value will always be used for the render.

This is intended to be used for modifying the style through external
parameters such as an input field, a slider, mouse position etc.
This commit is contained in:
Olivier Guyot
2019-10-22 14:23:54 +02:00
parent a1c00744d1
commit a0b271a812
3 changed files with 84 additions and 23 deletions
+5
View File
@@ -12,6 +12,9 @@
*
* * Reading operators:
* * `['get', 'attributeName']` fetches a feature attribute (it will be prefixed by `a_` in the shader)
* Note: those will be taken from the attributes provided to the renderer
* * `['var', 'varName']` fetches a value from the style variables, or 0 if undefined
* * `['time']` returns the time in seconds since the creation of the layer
*
* * Math operators:
* * `['*', value1, value1]` multiplies value1 by value2
@@ -39,6 +42,8 @@
* @typedef {Object} LiteralStyle
* @property {ExpressionValue} [filter] Filter expression. If it resolves to a number strictly greater than 0, the
* point will be displayed. If undefined, all points will show.
* @property {Object<string, number>} [variables] Style variables; each variable must hold a number.
* Note: **this object is meant to be mutated**: changes to the values will immediately be visible on the rendered features
* @property {LiteralSymbolStyle} [symbol] Symbol representation.
*/