Skip to content

Layer filter ​

layer.filter combines two things: a fixed server-side filter, and the filter panel through which users narrow a layer in the layer view. Both use filter expressions.

Server side ​

  • default is read by the XYZ API from the workspace layer, not from the request, and is applied to every layer query with ${filter}. A client cannot change or remove it.[1] It may be an expression object, an array (OR), or a SQL string. A string is inserted as SQL unchanged, so it must only come from the workspace.
  • current is the filter the user applied. The MAPP library sends it with layer queries and the API adds it to default with AND.

Client side ​

The MAPP library decorates every layer with filter: { current: {} } merged with the configured object. viewport is set to true when layer.params or layer.queryparams restrict queries to the viewport.[2]

The panel lists a filter for each layer.infoj entry which has a filter (true, a type string, or an object with type). Without one, an entry is listed when includeAll is set or its field is in include. Entries with skipEntry, without field, with filter: false, or whose field is in exclude are never listed.[3] The filter types and the keys inside entry.filter are described in entry filters.

  • hidden suppresses the panel; drawer defaults to disableOnHide, which disables the drawer while the layer is hidden. popout: true adds a button which opens the drawer in a dialog; dialog (true or dialog options) shows the panel in a dialog; classList is added to the drawer.
  • count_meta and viewport_description override the dictionary texts next to the location count.

Pitfalls ​

  • include and exclude list entry fields, not entry keys.
  • popout is a flag; an object is replaced by the drawer.
  • The legacy layer.multi_filter plugin key rewrites the filter configuration before the panel is built. Its other keys, such as target, are read by the plugin, not by the filter panel.[3:1]

Examples ​

The devdb retail points with a fixed default filter and a panel offering retailer, fascia and missing open date filters. Address fields are excluded.

json
{
  "dbs": "DEVDB",
  "locale": {
    "layers": {
      "retail_points": {
        "display": true,
        "format": "wkt",
        "table": "geodata.uk_glx_open_retail_points",
        "geom": "geom_p_4326",
        "srid": "4326",
        "qID": "id",
        "filter": {
          "default": { "size_band": { "ni": ["< 3,013 ft2 (280m2)"] } },
          "exclude": ["add_one", "add_two"]
        },
        "infoj": [
          { "type": "key" },
          { "title": "Retailer", "field": "retailer", "filter": "in" },
          { "title": "Fascia", "field": "fascia", "filter": { "type": "in", "dropdown": true } },
          { "title": "Open Date", "field": "open_date", "type": "date", "filter": { "type": "null", "label": "No open date" } },
          { "field": "add_one" },
          { "field": "add_two" }
        ]
      }
    }
  }
}

  1. query.js layerQuery ↩︎

  2. decorate.mjs ↩︎

  3. panels/filter.mjs listFilter, excludeEntry and multi_filter ↩︎ ↩︎

XYZ v5.1.0. Generated from knowledge/ at dd7a6fa27736502733499c1bf485f15659b10338. Concepts marked draft are not reviewed.