Allow registration of custom functions for expressions
This commit is contained in:
@@ -1 +1,2 @@
|
||||
@exportSymbol ol.expression.parse
|
||||
@exportSymbol ol.expression.register
|
||||
|
||||
@@ -32,7 +32,7 @@ ol.expression.evaluateFeature = function(expr, opt_feature) {
|
||||
|
||||
|
||||
/**
|
||||
* Parse an expression
|
||||
* Parse an expression.
|
||||
* @param {string} source The expression source (e.g. `'foo + 2'`).
|
||||
* @return {ol.expression.Expression} An expression instance that can be
|
||||
* evaluated within some scope to provide a value.
|
||||
@@ -43,6 +43,18 @@ ol.expression.parse = function(source) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Register a library function to be used in expressions.
|
||||
* @param {string} name The function name (e.g. 'myFunc').
|
||||
* @param {function(this:ol.Feature)} func The function to be called in an
|
||||
* expression. This function will be called with a feature as the `this`
|
||||
* argument when the expression is evaluated in the context of a features.
|
||||
*/
|
||||
ol.expression.register = function(name, func) {
|
||||
ol.expression.lib[name] = func;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Determines whether an expression is a call expression that calls one of the
|
||||
* `ol.expression.lib` functions.
|
||||
|
||||
Reference in New Issue
Block a user