The filters block

The filters block contains information on how the layer is being filtered before displaying. In order for a feature to be shown on the map it must evaluate the filter expression to true.

Filters are written using a JSON infix notation that looks like one of [identifier, operator, operand], true or false .

  • Valid identifiers are either a feature property or a nested expression.

  • Valid operators are:

    • "lt" – Less than

    • "gt" – Greater than

    • "le" – Less than or equal to

    • "ge" – Greater than or equal to

    • "eq" – Equal to

    • "ne" – Not equal to

    • "and" – And, cast to boolean

    • "or" – Or, cast to boolean

    • "cn" – Contains the operand, cast to string

    • "nc" – Does not contain the operand, cast to string

    • "in" – Contained in the operand list

    • "ni" – Not contained in the operand list

    • "is" – Used to match against null values

    • "isnt" – Used to match against null values

  • Operands are:

    • A numerical value, a string value, a boolean value

    • An array of numerical, string, or boolean values, a shorthand expanded to these patterns:

      • Input 1: [id, "in", [element1, …, elementN]

      • Expansion 1: id is equal (”eq”) to one of more of the elements

      • Input 2: [id, "ni", [element1, …, elementN]

      • Expansion 2: id is not equal (”ne”) to any of the elements

      • Not defined for operators other than "in" and "ni"

    • A nested expression

  • In cases of type mismatch cast the identifier value to the operand’s type

    • Type casting applies element-wise to lists with "in" and "ni" operators

Example of a filter block that filters out features with a value less than 50000 on the “acres” property
"filters": ["acres", "lt", 50000]
Example of a more complex filter block
"filters": [["acres", "ge", 50000], "and", ["acres", "le", 70000]]

Last updated