Accessibility & languages
A map canvas is a picture: a screen reader can’t see what is on it, and the buttons around it speak English unless you say otherwise. This guide covers what maplibre-yaml adds on top of what MapLibre already does: a name and description for each map, one table that translates the map’s text, and numbers in the reader’s language.
Checklist
Section titled “Checklist”For every map you publish:
- Give it a
title:and adescription:that say what it shows (below). - Set the page’s language (
<html lang="es">), and translate the map’s text withconfig.localeif the page isn’t in English (Show the map in another language). - Choose colours everyone can tell apart: the colour-blind-safe palettes are listed in Thematic maps › Colours. Don’t rely on colour alone where a label or popup can say the value.
Name and describe your map
Section titled “Name and describe your map”MapLibre makes every map canvas a named region a screen reader can jump to.
Its name is “Map”: on a page with three maps, a listener hears “Map, region”
three times. Give each map its own name with title:, and say what it shows
with description::
type: mapid: heattitle: Heat vulnerability in the Bronxdescription: > Census tracts shaded in five classes from pale yellow (low) to dark red (high). The highest values cluster along the Cross Bronx Expressway.config: center: [-73.88, 40.84] zoom: 11 mapStyle: "https://tiles.openfreemap.org/styles/liberty"A screen reader now announces “Heat vulnerability in the Bronx, region”
when the map gets focus, followed by the description. Neither is visible on
the page: title becomes the canvas’s aria-label, and description is a
visually hidden element the canvas points at with aria-describedby (also
read in a screen reader’s browse mode).
titleis a name, not a sentence: what you would put in a figure’s caption heading.descriptionis the map’s alt text. Say what it shows and what it means (“the highest values cluster along the expressway”), not how to use it (“drag to pan”). One or two sentences.- Without
titlethe map keeps MapLibre’s name, “Map” (translate it withMap.Titleinlocale:, below).
title: and description: sit at the top level of the document, next to
config:. Story maps and format v2 documents take them in the same place
(Other kinds of document).
What MapLibre already does
Section titled “What MapLibre already does”You don’t need to set any of this up:
- Keyboard. A focused map pans with the arrow keys, zooms with
+and-, and rotates and tilts with Shift + arrows. Every control button has a label. - Reduced motion. When the reader’s system asks for reduced motion,
camera moves (
flyTo, story chapter changes) jump instead of animating. MapLibre’sreduceMotionoption, written asconfig.reduceMotion: trueorfalse, overrides the system setting. - Right-to-left text. maplibre-gl 6.9 and later shape Arabic and Hebrew
labels by themselves. On an older maplibre-gl, call
setRTLTextPluginfrom your page, except under a Protomaps basemap labelled in Arabic, Hebrew, Persian or Urdu, for which maplibre-yaml sets it.
While the map loads
Section titled “While the map loads”While a map starts, <ml-map> carries aria-busy="true", so a screen reader
knows the region is still loading. If the map hasn’t drawn after about a
second, a “Loading map…” status appears in its middle until the basemap
draws. Its text is the maplibre-yaml.Loading key below. To use your own
loading indicator instead, see
<ml-map> styling hooks.
Show the map in another language
Section titled “Show the map in another language”MapLibre reads the text of its controls (“Zoom in”, “Close popup”) from a
locale: table in the map’s config. maplibre-yaml reads its own text (the
legend’s header, the “part of this map couldn’t load” notice, a story’s
chapter buttons) from the same table, under keys that start with
maplibre-yaml., so one table translates everything on the map:
type: mapid: calortitle: Vulnerabilidad al calor en el Bronxconfig: center: [-73.88, 40.84] zoom: 11 mapStyle: "https://tiles.openfreemap.org/styles/liberty" locale: # MapLibre's keys Map.Title: Mapa NavigationControl.ZoomIn: Acercar NavigationControl.ZoomOut: Alejar NavigationControl.ResetBearing: Restablecer la orientación Popup.Close: Cerrar # maplibre-yaml's keys maplibre-yaml.Legend.Title: Leyenda maplibre-yaml.Notice.Title: Parte de este mapa no se pudo cargar maplibre-yaml.Notice.Dismiss: Cerrar este avisocontrols: navigation: truelegend: items: - { color: "#fee08b", label: Bajo } - { color: "#d73027", label: Alto }A key you leave out stays in English. A misspelt maplibre-yaml. key is
reported by validation with a “did you mean”, since it would otherwise
silently do nothing.
Also set the page’s language (<html lang="es">, or lang="es" on
<ml-map>). Screen readers use it to pronounce the text, and numbers in
popups and legends follow it (Number formats). Basemap
labels are part of the basemap style; the gallery’s
Change a map’s language shows
how to switch them, and
Use locally generated ideographs
draws Chinese, Japanese and Korean labels from the reader’s own fonts.
maplibre-yaml’s keys
Section titled “maplibre-yaml’s keys”| Key | English | Where it appears |
|---|---|---|
maplibre-yaml.Legend.Title | Legend | The legend’s header (plain maps) and button (stories) |
maplibre-yaml.Notice.Title | Part of this map couldn’t load | The notice shown when a layer or data file fails |
maplibre-yaml.Notice.HintsTitle | Notes for this map’s author | The notice when it holds only author hints (shown while developing, or with debug) |
maplibre-yaml.Notice.AuthorDetails | Details for the site’s author | The notice’s disclosure; a story’s missing-image note |
maplibre-yaml.Notice.Dismiss | Dismiss this notice | The notice’s close button (label and tooltip) |
maplibre-yaml.Notice.More | …and {count} more (see the browser console). | The notice, past six problems |
maplibre-yaml.Notice.ZoomIn | Too many features to show here — zoom in to see them. | Over the map while a file read by view holds more features in view than one read takes |
maplibre-yaml.ErrorCard.HowToFix | How to fix it: | Error cards |
maplibre-yaml.ErrorCard.ConfigurationError | Configuration Error | Error card title (e.g. no mapStyle) |
maplibre-yaml.ErrorCard.MapError | Map Error | Error card title (the map couldn’t start) |
maplibre-yaml.ErrorCard.StyleNotLoaded | The basemap style didn’t load | Error card title |
maplibre-yaml.ErrorCard.StyleHint | Check {key}: open the URL in a new browser tab… | That card’s “how to fix it” |
maplibre-yaml.ErrorCard.LocalServer | Open this page through a local web server | Error card title (page opened from a file) |
maplibre-yaml.ErrorCard.LocalServerHint | Start a local web server in this page’s folder… | That card’s “how to fix it” |
maplibre-yaml.Loading | Loading map… | Shown in the middle of a map that takes more than a second to draw |
maplibre-yaml.HeightHint | This map is invisible because the <ml-map> element has no height… | Shown when the map has no height |
maplibre-yaml.Params.StateUnsupported | Parameter controls need maplibre-gl ≥ 5.6… | The params panel on old maplibre-gl |
maplibre-yaml.Story.Chapters | Story chapters | The chapter rail’s label |
maplibre-yaml.Story.GoToChapter | Go to chapter {number}: {title} | Each rail button’s label |
maplibre-yaml.Story.ImageMissing | This chapter’s image couldn’t load. | A chapter whose image failed |
maplibre-yaml.Story.VideoMissing | This chapter’s video couldn’t load. | A chapter whose video failed |
maplibre-yaml.Story.MediaMissingHint | ”{src}” didn’t load. Check the file name and folder… | That note’s details |
maplibre-yaml.Story.VideoUnsupported | Your browser does not support the video element. | Inside a chapter <video> |
maplibre-yaml.Classify.NoData | No data | A classify: layer’s legend line for features with no value |
maplibre-yaml.Classify.Other | Other | A classify: categories legend line for values not listed |
maplibre-yaml.FullPageMap.ResetView | Reset view | Astro <FullPageMap>’s reset button |
Text in {braces} is filled in when the string is shown: keep it in your
translation (Ir al capítulo {number}: {title}). Text in backticks inside a
message is shown as code.
MapLibre’s keys
Section titled “MapLibre’s keys”MapLibre’s own keys cover its controls: NavigationControl.ZoomIn,
NavigationControl.ZoomOut, NavigationControl.ResetBearing,
FullscreenControl.Enter, FullscreenControl.Exit,
GeolocateControl.FindMyLocation, ScaleControl.Kilometers, Popup.Close,
Map.Title and more; see MapLibre’s
defaultLocale
for the full list in your version. maplibre-yaml reads three of them too:
Map.Title (the map’s name when it has no title:), and
NavigationControl.ZoomIn / NavigationControl.ZoomOut (the zoom buttons
Astro’s <FullPageMap> draws).
What stays in English
Section titled “What stays in English”- Messages for the map’s author (why a layer didn’t draw, which file wasn’t found, “did you mean” hints) are in English; they are diagnostics, listed under the notice’s “Details for the site’s author”.
- Anything shown before the document is read (a
srcthat didn’t load, YAML that doesn’t parse, Astro’s “Loading story…”) has nolocale:to read yet. These only appear while a map is broken.
Adding a translation
Section titled “Adding a translation”maplibre-yaml ships English only. A translation is a locale: table: copy
the keys above (and MapLibre’s, if your map shows its controls) and translate
the values. A German table:
locale: Map.Title: Karte NavigationControl.ZoomIn: Vergrößern NavigationControl.ZoomOut: Verkleinern Popup.Close: Popup schließen maplibre-yaml.Legend.Title: Legende maplibre-yaml.Notice.Title: Ein Teil dieser Karte konnte nicht geladen werden maplibre-yaml.Notice.AuthorDetails: Details für die Person, die die Seite erstellt hat maplibre-yaml.Notice.Dismiss: Hinweis schließen maplibre-yaml.Story.Chapters: Kapitel der Geschichte maplibre-yaml.Story.GoToChapter: "Zu Kapitel {number}: {title}"Each map document needs its own copy of the table. A YAML anchor
reuses it only within one file, not across files. In Astro, keep the table in
one module and merge it into each document’s config.locale before passing
config to the component.
Your own controls, in the map’s language
Section titled “Your own controls, in the map’s language”Buttons you add next to the map (slot content) can use the same table:
<ml-map>’s uiString(key) returns the document’s text for a key, or the
English default.
const el = document.querySelector("ml-map");await el.mapReady();myZoomButton.ariaLabel = el.uiString("NavigationControl.ZoomIn");Number formats
Section titled “Number formats”A popup shows a number exactly as stored unless its item has a format:.
With one, the number follows the page’s language: on a page with
<html lang="de">, a rent of 1240.5 with
format: { currency: EUR, max-fraction-digits: 0 } reads “1.241 €”, and on
an English page “€1,241”. Legend edges of a classified
layer follow it the same way. The options and examples are in
Popups › Format numbers.
Other kinds of document
Section titled “Other kinds of document”The same keys work in a story map and in a format v2 document.
# A story map: the title names the story's map.type: scrollytellingid: bridgetitle: Crossing the Brooklyn Bridgedescription: A walk from Manhattan to Brooklyn in three chapters.config: center: [-73.9969, 40.7061] zoom: 15 mapStyle: "https://tiles.openfreemap.org/styles/liberty"chapters: - id: start title: City Hall Park center: [-74.0055, 40.7128] zoom: 16A story’s locale: table sits in config.locale, as in a map. In
format v2, title: and description: stay at the top
level and the table moves to runtime.map.locale:
version: 2type: mapid: heattitle: Heat vulnerability in the Bronxdescription: Census tracts shaded from pale yellow (low) to dark red (high).style: basemap: "https://tiles.openfreemap.org/styles/liberty" center: [-73.88, 40.84] zoom: 11When you export a map with mlym emit, title becomes the style’s name
and description is kept in its metadata (as maplibre-yaml:description).
See also
Section titled “See also”- Thematic maps & legends: the legend, and colour-blind-safe palettes.
- Reading what the map tells you:
the notice and error cards whose text the
maplibre-yaml.*keys translate. - The map reference:
title,descriptionandconfig.locale.