Skip to content

Locale view ​

Workspace Key draft workspace locale mapview mapp

Keys for the mapview a locale creates - start view, extent, zoom range, projection, controls, SVG templates and location records; use for every locale.

Resource and sources

The MAPP library creates the mapview from the locale.[1]

  • view is the start view: lat, lng and zoom z. URL hooks override it. Without z the map starts at minZoom. The object is passed to the Openlayers View, so view.minZoom and view.maxZoom take precedence over the locale keys, and other View options such as enableRotation apply; center, zoom, projection and extent are set by the mapview.
  • extent limits panning to north, south, east and west in degrees. An invalid extent falls back to the world with a warning. mask greys out everything outside the extent.
  • minZoom and maxZoom limit zooming.
  • srid is the EPSG code of the mapview projection, 3857 by default. Openlayers knows only 3857 and 4326; other projections must be added with mapp.utils.proj4.addProjection before the mapview is created.
  • ScaleLine adds a scale bar in metric or imperial units; any other value shows metric.
  • mapviewControls adds Openlayers controls by class name, eg. ["Zoom"], created without options from the ol.control of the page (Openlayers 10 in the default view). Names not in ol.control are ignored.
  • svgTemplates maps names to SVG URLs which are loaded before layers render, for icons with type: template. svg_templates is the deprecated name, still read when svgTemplates is not set.
  • listview_records sets the symbols and colours of the location list, eg. [{ "symbol": "1", "colour": "#000" }]; the default is A to J.[2]

Pitfalls ​

  • bounds, maskBounds, showScaleBar and scalebar are legacy keys, renamed or converted with a warning.
  • Latitudes and longitudes are degrees; an extent with north below south or east below west falls back to the world. Zooms have no upper limit here; without maxZoom Openlayers stops at zoom 28.
  • The extent does not change the minimum zoom; set minZoom to stop users zooming out past the extent.

Examples ​

A UK locale with a masked extent, metric scale bar and zoom range.

json
{
  "dbs": "DEVDB",
  "locale": {
    "view": { "lat": 51.5, "lng": -0.1, "z": 10 },
    "extent": { "north": 61, "south": 49.8, "east": 2, "west": -8.7, "mask": true },
    "minZoom": 5,
    "maxZoom": 18,
    "ScaleLine": "metric",
    "mapviewControls": ["Rotate"],
    "layers": {
      "retail_points": {
        "display": true,
        "format": "wkt",
        "table": "geodata.uk_glx_open_retail_points",
        "geom": "geom_p_4326",
        "srid": "4326",
        "qID": "id"
      }
    }
  }
}

  1. mapp mapview/_mapview.mjs viewConfig, viewExtent, mapviewControls, viewMask ↩︎

  2. ui locations/listview.mjs ↩︎

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