Skip to content

Locale plugins ​

A plugin is a method in mapp.plugins. A locale key with the name of a plugin runs that plugin with the key's value as configuration and the mapview, after the mapview is created and before its layers are added.[1] Errors are logged and do not stop the mapview.

The ui library provides admin, custom_theme, dark_mode, feature_info, fullscreen, link_button, locator, login, userIDB, userLayer, userLocale, zoomBtn and zoomToArea, eg. "fullscreen": true.[2] The MAPP library provides consent, layer_order and svg_templates. The options of consent, feature_info, link_button and userIDB are described in plugin options.

The MAPP library's layer_order plugin sorts locale.layers by a list of layer keys. Layers are added with increasing zIndex, so later keys are drawn on top; layers not in the list keep their order and go to the end, on top of the listed layers.[3]

Loading plugins ​

plugins lists URLs of plugin modules to import first, eg. the tabulator and chartjs dataview plugins from the public plugins. The XYZ API replaces ${NAME} in each URL with the SRC_NAME environment variable.[4] layer.plugins are added to the locale's list.

syncPlugins lists plugin keys which run first, one after another, in order; the rest run in parallel. The default view sets it to zoomBtn, admin, login, which orders the buttons. Layer keys matching a plugin run it for that layer; see layer display.

Pitfalls ​

  • A plugin URL is loaded into every user's browser. Only list sources the deployment controls.
  • A locale key which is not a plugin is ignored, so a misspelt plugin key does nothing.

Examples ​

The fullscreen and locator buttons, with the zoom button first.

json
{
  "dbs": "DEVDB",
  "locale": {
    "syncPlugins": ["zoomBtn"],
    "zoomBtn": true,
    "fullscreen": true,
    "locator": true,
    "layers": {
      "countries": {
        "display": true,
        "format": "geojson",
        "table": "naturalearth.countries",
        "geom": "geom_4326",
        "srid": "4326",
        "qID": "id"
      }
    }
  }
}

  1. mapp mapview/_mapview.mjs mapviewPromise and executePlugin ↩︎

  2. ui plugins/_plugins.mjs ↩︎

  3. mapp plugins/layer_order.mjs and its tests ↩︎

  4. utils/envReplace.js ↩︎

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