Skip to content

Layer display and view ​

Workspace Key draft workspace layer mapp ui

Keys that name a layer, decide whether it is shown and how its view appears in the layers list; use for every layer.

Resource and sources

A layer is a JSON object in locale.layers, keyed by its layer key. The XYZ API assigns the key as layer.key and, without a name, as the name. The MAPP library decorates the layer when it is added to a mapview.[1]

  • display shows the layer when the mapview is created. In a mapview with URL hooks, a layers URL parameter decides instead.
  • hidden creates no layer view in the layers list. The layer is still in mapview.layers and can be shown programmatically.
  • name is the header of the layer view. meta is HTML shown in the view.
  • group puts layer views with the same value into one group drawer; groupmeta is HTML shown in the group. groupClassList adds CSS classes to the group drawer; the first layer of the group creates the drawer, so only its value applies.[2]
  • attribution maps source names to URLs, shown in the map attribution while the layer is displayed.
  • zIndex orders the layer canvas. Without one, layers get increasing values in locale order, so later layers draw on top. promoteDisplay draws the layer above all displayed layers whenever it is shown.

Layer view ​

viewConfig controls the layer view in the layers list:[3]

  • displayToggle, zoomToFilteredExtentBtn and popoutBtn add header buttons; headerOrder orders them.
  • zoomBtn and hideDisabled only apply to layers with tables, which have a zoom range: a zoom button, and hiding the view outside the range.
  • panelOrder sorts the view drawers by their data-id, eg. filter-drawer. keyOrder orders the layer keys whose panel methods create the drawers.
  • classList is added to the view drawer element.

panelOrder, zoomBtn, popout and drawer directly on the layer are legacy forms which the ui copies into viewConfig.

Any layer key which matches a mapp.layer method or a mapp.plugins method calls that method with the decorated layer, so a plugin is configured by adding its key to the layer.[1:1]

Pitfalls ​

  • A layer whose format is not a registered format is skipped with a console warning; see layer formats.
  • A plugin key with a typo is ignored silently.

Examples ​

Two layers in one group; the second is not displayed when the map opens.

json
{
  "dbs": "DEVDB",
  "locale": {
    "layers": {
      "locations": {
        "name": "Capitals",
        "group": "Examples",
        "display": true,
        "format": "wkt",
        "table": "example.locations",
        "geom": "geom",
        "srid": "4326",
        "qID": "id"
      },
      "features": {
        "name": "Features",
        "group": "Examples",
        "meta": "Polygons and lines in EPSG:3857.",
        "display": false,
        "format": "wkt",
        "table": "example.features",
        "geom": "geom",
        "srid": "3857",
        "qID": "id"
      }
    }
  }
}

  1. decorate.mjs ↩︎ ↩︎

  2. ui layers/listview.mjs createGroup ↩︎

  3. ui layers/view.mjs viewConfig ↩︎

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