Filter
Filter expressions are used to target specific data in a layer. This library implements the semantics specified by the Mapbox GL JS spec.
API
featureFilter(filter)
Given a filter expressed as nested arrays, return a new function
that evaluates whether a given feature (with a .properties or .tags property)
passes its test.
Parameters
parameter | type | description |
---|
filter | Array | mapbox gl filter |
Returns Function
, filter-evaluating function
Usage
var ff = require('feature-filter');
var filter = [
"all",
["==", "class", "street_limited"],
["<=", "admin_level", 3],
["!=", "$type", "Polygon"]
]
var testFilter = ff(filter);
var feature = {
type: 2,
properties: {
class: "street_limited"
admin_level: 1
}
};
return testFilter(feature);