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.
The map doesn’t show
Section titled “The map doesn’t show”| Symptom | Cause | Fix |
|---|---|---|
| Nothing where the map should be, no error | The element has no height | Give <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 console | The import map is missing, or comes after the script | Copy the <head> from Browser usage (CDN) |
| A card saying the page was opened from a file | The HTML file was double-clicked (a file:// address), and browsers block it from fetching the YAML | Serve the folder: Run a local server |
| A blank map and Worker failed to load | maplibre-gl 6 inside a bundler can’t find its worker | Set the worker URL: Worker failed to load |
The element stays empty and customElements.get("ml-map") is undefined | The 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 error | Fix the line the card names: An error card instead of the map |
YAML syntax error … <!doctype html> after npm run build | map.yaml is next to index.html, so the build doesn’t copy it | Move it into public/: Using a bundler (Vite) |
| A card asking for a basemap | config: has no mapStyle | Add one: The basemap |
| The map is in the ocean, or far from your data | center is written latitude first | Write [longitude, latitude]: Coordinates |
The map shows, but your data doesn’t
Section titled “The map shows, but your data doesn’t”| Symptom | Cause | Fix |
|---|---|---|
| The basemap draws, your layer doesn’t | A path, the file, CORS or the layer’s style | Read the notice on the map, then The basemap draws but your layer doesn’t |
| A local data file isn’t found | Paths are relative to the page, not to the YAML | Using your own data file |
| A data file on another site doesn’t load, with a CORS error in the console | That server doesn’t let other sites read the file | CORS considerations |
| ”CSV files aren’t supported” | A source can’t read a table | Convert the table to GeoJSON: CSV and spreadsheets |
| A colour is ignored, or the layer fails validation | The colour isn’t in quotes, and # starts a comment in YAML | Quote it: circle-color: "#e74c3c" |
A warning about a value starting with = | Values starting with = are reserved | Strings starting with = are reserved |
| Your page’s JavaScript never sees the map’s events | The listener was added after the event fired, or an error stopped the map first | Events not firing |
Popups, hover and legends
Section titled “Popups, hover and legends”| Symptom | Cause | Fix |
|---|---|---|
| Clicking a feature does nothing | The 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 be | The property: name doesn’t match the data (names are case-sensitive), or that feature has no such value | Copy the name from the data file; else: sets text for a missing value: Choose what the popup shows |
| No legend appears | Nothing gives the legend entries | Add legend: { label, color } to a layer, or classify it: The legend |
| A legend appears that you don’t want | A classified layer, or a layer’s legend: entry, makes one | Write legend: false at the top level of the document |
Story maps
Section titled “Story maps”| Symptom | Cause | Fix |
|---|---|---|
| A card in place of the story | The story file has a YAML or validation error, or wasn’t found | Fix 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 unchanged | Give each chapter its own id |
| A chapter doesn’t show or hide a layer | Its layers.show or layers.hide names a layer id that doesn’t exist | While you develop, the notice names it with a “did you mean”; match the layer’s id |
| A chapter’s image doesn’t load | The path is wrong, or the site is under a subpath | Paths 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”| Symptom | Cause | Fix |
|---|---|---|
| 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 folder | Set the base: Publishing & subpaths (HTML pages, Astro) |
Every file 404s on your computer after adding base | The local server isn’t serving the site under the same subpath | Previewing a subpath |
| Author hints you saw while developing are gone | They show only while you develop | Expected; add debug to see them: When are author hints shown? |
| Something changed after upgrading | A behaviour change in the new release | Upgrading to 0.10 |
Reading what the map tells you
Section titled “Reading what the map tells you”<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
srcfile 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, acenterthat looks written latitude first, abefore: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).
When are author hints shown?
Section titled “When are author hints shown?”Failures always show. Author hints show when any of these is true, and stay off the page otherwise:
| Situation | Author 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:// page | shown |
A bundler development build: astro dev or vite, on any address, a Codespaces URL included | shown |
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 script | hidden |
The element has quiet | hidden, and so are failures |
Every hint is still written to the browser console, wherever the page runs.
debug and quiet
Section titled “debug and quiet”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 />.
Common problems in detail
Section titled “Common problems in detail”The map has no height
Section titled “The map has no height”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;" />.
<ml-map> isn’t defined
Section titled “<ml-map> isn’t defined”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-gland theregister.jsscript, 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/registerin 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.
Blank map and “Worker failed to load”
Section titled “Blank map and “Worker failed to load””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).
An error card instead of the map
Section titled “An error card instead of the map”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 centerconfig:center: [-74, 40]zoom: 10 -
A missing required key. A map needs
type: map, anid, and aconfig:withcenter,zoomandmapStyle(the basemap).type: mapid: my-mapconfig:center: [-74.006, 40.7128]zoom: 10mapStyle: "https://tiles.openfreemap.org/styles/liberty"layers: [] -
A wrong value.
centeris[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:
-
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). -
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.
-
CORS. A file on another site must allow your page to read it; the console shows a CORS error if not (CORS considerations).
-
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)); -
The style. A colour without quotes, a
filter:that matches nothing, or aminzoomabove 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.
| Symptom | Cause | Fix |
|---|---|---|
”served without range-request support”, often with python -m http.server | The server sends whole files only | Use 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 incomplete | Upload 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 header | CORS rule |
| ”is in EPSG:…” | The file is in another projection | FlatGeobuf 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 itself | Only the script was copied, not the whole dist/ folder | Hosting the files yourself |
| A Protomaps basemap draws without labels or icons, or the notice names the fonts or icons | Labels come from Protomaps’ font host unless you copy them | Host your own basemap |
| ”too large to load whole in a browser” | The source reads the whole file, and this one is too big for that | Add load: viewport or convert the file: When something goes wrong |
| Symptom | Where to look |
|---|---|
ReferenceError: HTMLElement is not defined | HTMLElement is not defined |
A saved YAML change doesn’t appear in astro dev | Editing in astro dev |
<Map src> gives a 404 | src is the address on the site, without public/: Incorrect src path |
A page using loadMapConfig fails with ENOENT on a server | Server output (SSR) |
| More Astro problems | Astro troubleshooting |
| Symptom | Where to look |
|---|---|
mlym: command not found, or npx mlym fails with a 404 | Use npx maplibre-yaml@latest, or install the CLI: Short alias, Command not found |
| No autocomplete or checking in your editor | Editor setup |
mlym validate errors don’t show in VS Code’s Problems panel | Validate on save (VS Code task) |