Skip to content

MAPP.UI ​

Guide draft ui mapp architecture browser

How the MAPP.UI library in apps/ui builds on the mapp global, its module map (elements, layers, locations, plugins, Dataview, Tabview, Gazetteer) and how views wire it to a mapview; use before changing ui modules or the default view.

Resource and sources

MAPP.UI builds the interface around a MAPP mapview: layer and location views, filters, legends, dataviews, tabs, the gazetteer and mapview buttons. It lives in apps/ui (@geolytix/mapp-ui) and is bundled as public/js/lib/ui.js with public/css/ui.css. For the library split see MAPP.

The mapp global ​

MAPP.UI imports nothing from apps/mapp. It uses MAPP through the mapp global, eg. mapp.utils, mapp.dictionary, mapp.layer, mapp.user, mapp.hooks and mapp.host. mapp.js must load before ui.js.[1]

On load, ui.mjs assigns itself as mapp.ui and globalThis.ui, and patches MAPP:[2]

  • mapp.utils.alert() and confirm() become ui dialogs.
  • mapp.layer.drawLegend() becomes the ui legend renderer.
  • the ui plugins are added to mapp.plugins.

The dependency runs one way. MAPP must work without MAPP.UI; the lint workflow fails if apps/mapp/lib references mapp.ui or imports from apps/ui.[3] MAPP therefore never calls the ui. The ui hooks in through objects MAPP already uses, listed below. Loading mapp.js again after ui.js replaces the global and drops the ui.

Module map ​

ModuleRole
elements/Generic controls: dialog, drawer, dropdown, slider, pills, searchbox, toast, login and register forms.
layers/Layer listview, layer view, panels (meta, style, filter, dataviews, draw, ...), legends and filters.
locations/Location listview, location view, infoj and entries per entry type.
plugins/Mapview buttons and tools: zoomBtn, admin, login, locator, fullscreen, dark_mode, userLayer, ...
utils/Dataview helpers, histogram, colour theme, idle logout, resize handler.
Dataview.mjsDecorates a dataview: JSON, Tabulator table or ChartJS chart.
Tabview.mjsTabs and panels, eg. the dataview tabs below the map.
Gazetteer.mjsSearch box over mapp.utils.gazetteer.

How the ui attaches to MAPP ​

  • Views wire it up. A view script such as _default.html creates the mapp.Mapview, then calls mapp.ui.layers.listview, mapp.ui.locations.listview, mapp.ui.Gazetteer and mapp.ui.Tabview with its own target elements. MAPP alone renders a map without these panels.
  • Layers. The layer listview creates a layer.view for each mapview layer. The view calls mapp.ui.layers.panels[key] for each layer key with a panel, ordered by viewConfig.keyOrder.[4] A new panel is a new module in layers/panels named after its layer key.
  • Locations. The location listview replaces mapview.locations with a Proxy. When MAPP stores a location there, the proxy assigns a record symbol and colour and calls mapp.ui.locations.view.[5] The view renders location.infoj; each entry is drawn by mapp.ui.locations.entries[entry.type].[6]
  • Plugins. MAPP calls mapp.plugins[key](locale[key], mapview) for each locale key with a plugin function.[7] Ui plugins add buttons to the mapview and need MAPP.UI loaded. See Locale plugins.
  • Dataviews. Chart and table dataviews need ChartJS or Tabulator loaded by a plugin; Dataview checks for them. See Dataviews.

Where to change ​

  • A new control: a module in elements/ and its export in _elements.mjs.
  • A new entry type: a module in locations/entries/ and _entries.mjs; document it in Entry types.
  • A new layer panel: a module in layers/panels/ and _panels.mjs.
  • A new mapview button: a plugin in plugins/ and _plugins.mjs; document its locale key in Locale plugins.
  • Behaviour MAPP needs without the ui belongs in apps/mapp/lib, with a plain fallback the ui can replace, like drawLegend.
  • Styles: apps/ui/css, bundled from _ui.css. ui.css loads the fonts and palette that mapp.css relies on.

Tests ​

apps/ui/tests has Vitest browser module tests (*.test.mjs) mirroring lib/, and Playwright tests of the default view (*.spec.mjs), both against the testhost. Run pnpm test:ui; see TESTING.md. Many ui modules have no tests yet.


  1. apps/ui/README.md ↩︎

  2. apps/ui/lib/ui.mjs ↩︎

  3. .github/workflows/biome.yml ↩︎

  4. apps/ui/lib/layers/view.mjs ↩︎

  5. apps/ui/lib/locations/listview.mjs ↩︎

  6. apps/ui/lib/locations/infoj.mjs ↩︎

  7. apps/mapp/lib/mapview/_mapview.mjs ↩︎

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