Skip to content

Troubleshooting

Start with what the map itself says: an error card or a notice on the map usually names the problem and the fix, and the browser console (F12) has every message. Then find your symptom in the tables below: each row gives the likely cause and the fix, or links to the section that explains it.

SymptomCauseFix
Nothing where the map should be, no errorThe element has no heightGive <ml-map> display: block and a height: The map has no height
A blank page, and Failed to resolve module specifier “maplibre-gl” in the consoleThe import map is missing, or comes after the scriptCopy the <head> from Browser usage (CDN)
A card saying the page was opened from a fileThe HTML file was double-clicked (a file:// address), and browsers block it from fetching the YAMLServe the folder: Run a local server
A blank map and Worker failed to loadmaplibre-gl 6 inside a bundler can’t find its workerSet the worker URL: Worker failed to load
The element stays empty and customElements.get("ml-map") is undefinedThe script that defines <ml-map> didn’t run<ml-map> isn’t defined
A card in place of the map (“Configuration Error”)The document has a YAML or validation errorFix the line the card names: An error card instead of the map
YAML syntax error … <!doctype html> after npm run buildmap.yaml is next to index.html, so the build doesn’t copy itMove it into public/: Using a bundler (Vite)
A card asking for a basemapconfig: has no mapStyleAdd one: The basemap
The map is in the ocean, or far from your datacenter is written latitude firstWrite [longitude, latitude]: Coordinates
SymptomCauseFix
The basemap draws, your layer doesn’tA path, the file, CORS or the layer’s styleRead the notice on the map, then The basemap draws but your layer doesn’t
A local data file isn’t foundPaths are relative to the page, not to the YAMLUsing your own data file
A data file on another site doesn’t load, with a CORS error in the consoleThat server doesn’t let other sites read the fileCORS considerations
”CSV files aren’t supported”A source can’t read a tableConvert the table to GeoJSON: CSV and spreadsheets
A colour is ignored, or the layer fails validationThe colour isn’t in quotes, and # starts a comment in YAMLQuote it: circle-color: "#e74c3c"
A warning about a value starting with =Values starting with = are reservedStrings starting with = are reserved
Your page’s JavaScript never sees the map’s eventsThe listener was added after the event fired, or an error stopped the map firstEvents not firing
SymptomCauseFix
Clicking a feature does nothingThe layer has no interactive: block, or it is indented under paint: or source:Put interactive: on the layer, at the same depth as paint:: Show a popup on click
A popup has a blank where a value should beThe property: name doesn’t match the data (names are case-sensitive), or that feature has no such valueCopy the name from the data file; else: sets text for a missing value: Choose what the popup shows
No legend appearsNothing gives the legend entriesAdd legend: { label, color } to a layer, or classify it: The legend
A legend appears that you don’t wantA classified layer, or a layer’s legend: entry, makes oneWrite legend: false at the top level of the document
SymptomCauseFix
A card in place of the storyThe story file has a YAML or validation error, or wasn’t foundFix the line the card names, as for a map: An error card instead of the map
Two chapters have id …A chapter was copied and its id left unchangedGive each chapter its own id
A chapter doesn’t show or hide a layerIts layers.show or layers.hide names a layer id that doesn’t existWhile you develop, the notice names it with a “did you mean”; match the layer’s id
A chapter’s image doesn’t loadThe path is wrong, or the site is under a subpathPaths are relative to the page; on a subpath set base: Publishing & subpaths

Works on your computer, not once published

Section titled “Works on your computer, not once published”
SymptomCauseFix
A 404 for the YAML or the data on GitHub Pages (or any site under a subpath)Paths starting with / point at the domain’s root, not your site’s folderSet the base: Publishing & subpaths (HTML pages, Astro)
Every file 404s on your computer after adding baseThe local server isn’t serving the site under the same subpathPreviewing a subpath
Author hints you saw while developing are goneThey show only while you developExpected; add debug to see them: When are author hints shown?
Something changed after upgradingA behaviour change in the new releaseUpgrading to 0.10

<ml-map> and <ml-scrollytelling>, and the Astro components that render them, report problems on the page as well as in the console:

  • Error card, in place of the map: the document can’t render at all. A YAML syntax error, a validation error with its line number (and, for a typo, a “did you mean”), a src file that isn’t found (with the full address the browser asked for), a page opened from a file, or a basemap that won’t load. Fix what the card names and reload.
  • Notice, over the map and dismissible: the map works but part of it didn’t load, such as a layer MapLibre rejected, a data file that didn’t load, or an image or marker icon that failed. Each line names the layer or file. A visitor sees “Part of this map couldn’t load”; the fix is in “Details for the site’s author” below it, open while you develop and one click away on a published site.
  • Author hints, in the same notice: the map works, but the document probably doesn’t say what you meant. A near-miss name, a key nested under config: that belongs at the top level, a center that looks written latitude first, a before: naming a layer the map doesn’t have, a chapter naming a missing layer. They are for you, not your visitors, so they show only while you develop (below).
  • Height hint: a map with no height shows a short note asking for one (The map has no height).

A slow map shows “Loading map…” in its middle until the basemap draws. That is not a problem report; to hide it or style it, see the <ml-map> styling hooks.

To catch mistakes before you load the page, run npx maplibre-yaml@latest validate map.yaml (The CLI), or set up your editor to check the YAML as you type. Page scripts can listen for the same problems as events (ml-map:error and the others).

Failures always show. Author hints show when any of these is true, and stay off the page otherwise:

SituationAuthor hints
The page is served from your computer: localhost, 127.0.0.1, [::1], 0.0.0.0 or [::] (a dev server started with --host), or opened as a file:// pageshown
A bundler development build: astro dev or vite, on any address, a Codespaces URL includedshown
The element has the debug attribute (or its <ml-scrollytelling> does; in Astro, the debug prop)shown, wherever the page is served
A published site (GitHub Pages, Netlify, your own domain), including a page using the CDN scripthidden
The element has quiethidden, and so are failures

Every hint is still written to the browser console, wherever the page runs.

To check a deployed site, add debug to see the author hints there:

<ml-map src="/maps/city.yaml" debug></ml-map>

Add quiet to keep the notice (failures and hints) and the height hint off the page, for a site that would rather fail quietly. The problems are still logged to the console and dispatched as events. quiet wins over debug. The error card always shows.

<ml-map src="/maps/city.yaml" quiet></ml-map>

The Astro Map, FullPageMap and Scrollytelling components take the same two as props: <Map src="…" debug />.

What you see: nothing where the map should be, no error, or a map a few pixels tall. Unless it has quiet, the element shows a short note asking for a height.

<ml-map> has no size of its own, and neither does a <div> you hand to the JavaScript API. Give it a height and display: block:

ml-map {
display: block; /* required: a custom element is inline by default */
width: 100%;
height: 400px; /* or 100vh to fill the window */
}

The Astro Map component sets a height for you (400px by default, the height prop changes it), and FullPageMap fills the window. A component of your own around <ml-map> needs both properties: <ml-map src="/configs/map.yaml" style="height: 400px; display: block;" />.

What you see: the element is on the page but stays empty, and customElements.get("ml-map") in the console returns undefined.

The script that registers the element didn’t run:

  • From a CDN: the page needs both the import map for maplibre-gl and the register.js script, as in Browser usage (CDN). A Failed to resolve module specifier “maplibre-gl” error in the console means the import map is missing or comes after the script.
  • With a bundler: import @maplibre-yaml/core/register in code that runs in the browser (Using a bundler).
  • In Astro: import it in a <script> tag, never in the frontmatter (HTMLElement is not defined), or use the package’s <Map> component, which does it for you.

What you see: the map area stays empty, or shows a Map Error card saying Worker failed to load; the console names maplibre-gl-worker.mjs.

maplibre-gl 6 draws in a background worker loaded from a separate file, and inside a bundle (Vite, Astro, webpack) it can’t find that file unless it is told where it is. Import the worker’s URL and pass it to setWorkerUrl() in the same entry file that imports @maplibre-yaml/core/register: the four lines are in Using a bundler (Vite).

A CDN page needs nothing (the worker loads from the CDN), and maplibre-gl 4 and 5 need nothing. The @maplibre-yaml/astro components set the worker for you; a component of your own around <ml-map> does it in its <script> (Using <ml-map> directly).

What you see: a card in place of the map (for example “Configuration Error”) listing the problem with its line, such as id: The document is missing id: — add id: a-short-name.

The document failed to load, parse or validate. The card names the field; the common causes:

  • Indentation. YAML nests by indentation: use spaces (two per level), never tabs, and keep sibling keys at the same depth.

    # Wrong: zoom is indented differently from center
    config:
    center: [-74, 40]
    zoom: 10
  • A missing required key. A map needs type: map, an id, and a config: with center, zoom and mapStyle (the basemap).

    type: map
    id: my-map
    config:
    center: [-74.006, 40.7128]
    zoom: 10
    mapStyle: "https://tiles.openfreemap.org/styles/liberty"
    layers: []
  • A wrong value. center is [longitude, latitude] (two numbers), not a place name; colours go in quotes, because in YAML # starts a comment.

  • A file that isn’t found. The card shows the address the browser asked for. Paths are relative to the page, or under public/ with a bundler or Astro; on a site under a subpath, see Publishing & subpaths.

YAML inside a JavaScript template literal or a <script type="text/yaml"> tag has its own indentation pitfall: Template literal YAML issues.

The basemap draws but your layer doesn’t

Section titled “The basemap draws but your layer doesn’t”

First read the notice at the top of the map, if there is one: it names each layer that didn’t draw and each data file that didn’t load, with the address the browser tried. Then check:

  1. The path. Relative data paths resolve against the page, not the YAML file (Using your own data file). On a site under a subpath, set base (Publishing & subpaths).

  2. The file. Open its URL in the browser: it should be GeoJSON, not a web page or a 404. In the developer tools’ Network tab, find the request.

  3. CORS. A file on another site must allow your page to read it; the console shows a CORS error if not (CORS considerations).

  4. The features. A file with no features, or features without geometry, loads but draws nothing. Page scripts can log what loaded:

    const mapEl = document.querySelector("ml-map");
    mapEl.addEventListener("ml-map:layer-data-loaded", (e) =>
    console.log("Loaded:", e.detail.layerId, e.detail.featureCount)
    );
    mapEl.addEventListener("ml-map:layer-data-error", (e) =>
    console.error("Error:", e.detail.layerId, e.detail.error)
    );
  5. The style. A colour without quotes, a filter: that matches nothing, or a minzoom above the current zoom hide a layer that did load.

Large data: PMTiles, FlatGeobuf, GeoParquet and COG

Section titled “Large data: PMTiles, FlatGeobuf, GeoParquet and COG”

When one of these files fails, the rest of the map still draws and the notice says why. The common messages, with the fix for each, are in When something goes wrong.

SymptomCauseFix
”served without range-request support”, often with python -m http.serverThe server sends whole files onlyUse a server with range requests (npx serve, GitHub Pages, Netlify, S3): Range requests and CORS
A 416 status (Range Not Satisfiable)The file was found, but the server refused the part asked for: the upload may be incompleteUpload the file again, or try another host (Range requests and CORS)
A file on another site is blocked (CORS)The other server doesn’t allow your site, or the Range headerCORS rule
”is in EPSG:…”The file is in another projectionFlatGeobuf needs longitude/latitude (EPSG:4326), a COG Web Mercator (EPSG:3857); the notice gives the command that converts it (details)
“The … reader (…/chunks/….js) couldn’t be downloaded”, on a site hosting maplibre-yaml’s files itselfOnly the script was copied, not the whole dist/ folderHosting the files yourself
A Protomaps basemap draws without labels or icons, or the notice names the fonts or iconsLabels come from Protomaps’ font host unless you copy themHost your own basemap
”too large to load whole in a browser”The source reads the whole file, and this one is too big for thatAdd load: viewport or convert the file: When something goes wrong
SymptomWhere to look
ReferenceError: HTMLElement is not definedHTMLElement is not defined
A saved YAML change doesn’t appear in astro devEditing in astro dev
<Map src> gives a 404src is the address on the site, without public/: Incorrect src path
A page using loadMapConfig fails with ENOENT on a serverServer output (SSR)
More Astro problemsAstro troubleshooting
SymptomWhere to look
mlym: command not found, or npx mlym fails with a 404Use npx maplibre-yaml@latest, or install the CLI: Short alias, Command not found
No autocomplete or checking in your editorEditor setup
mlym validate errors don’t show in VS Code’s Problems panelValidate on save (VS Code task)