Diagnoses why a MapLibre GL JS source isn't rendering — covers TileJSON url vs tiles templates, source-layer matching, layer ordering, promoteId, feature state, and CORS/glyph failures behind a blank map.
Ships in maplibre-agent-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use this only when a source is configured and the map is wrong with no error, in one of the ways listed below, or when choosing how a source should reference a tile endpoint. For any other MapLibre question, such as how to style a layer that already draws, answer it as asked and stop when the question is answered: no troubleshooting, tips, pitfalls or gotchas section, no table of issues to check, and nothing from this skill, since none of it applies.
This skill covers connecting a source to a style correctly, and the failure modes that look identical from the outside.
The source is already configured and the map is wrong in a way that produces no error. These are symptoms as you would observe them, before you know the cause:
url
at its TileJSON instead of hand-writing tilesNot this skill. Text in the wrong font, missing scripts, or self-hosting glyph PBFs — maplibre-fonts-glyphs. Deciding the colors, type, and drawing order of a style you are designing — maplibre-cartography. Deciding whether a dataset belongs in GeoJSON or vector tiles at all — maplibre-tile-sources.
url vs tilesTiles are addressed by zoom (Z), column (X), and row (Y) — a universal scheme across raster and vector tile sources (see the OpenStreetMap wiki for more information). In a MapLibre source, you reference tiles either directly via a tiles URL template or via a url pointing to a TileJSON endpoint.
When a TileJSON endpoint is available, prefer url. A hand-wired tiles array has no zoom range unless you supply one: MapLibre assumes maxzoom: 22 and requests zoom levels the tileset doesn't contain, which come back empty — tiles that show and then vanish as you zoom in. With url, MapLibre fetches the document and reads the tile URL template, zoom range (minzoom/maxzoom), bounds, attribution, and (for vector tiles) the available source-layers automatically. Tile servers like Martin and tileserver-gl generate TileJSON endpoints for every tileset they serve, as do many hosted providers.
When no TileJSON endpoint exists — for example, a raw raster tile service that gives you a URL template directly — use the tiles array and specify any metadata (minzoom, maxzoom, attribution) in the source definition yourself.
url to a TileJSON endpoint:
{
"type": "vector",
"url": "https://example.com/tiles.json"
}
tiles array:
{
"type": "vector",
"tiles": ["https://example.com/tiles/{z}/{x}/{y}.pbf"],
"minzoom": 0,
"maxzoom": 14
}
{z}, {x} and {y} are tokens MapLibre replaces with each tile's zoom, column and row before it makes a request. A template pasted into a browser with the braces still in it asks for no real tile, so its status code says nothing about the server. To check the server by hand, request a real tile inside the source's zoom range, such as /0/0/0.pbf.
Hand-wiring tiles for a PMTiles archive has the same cost, and a sharper one — see maplibre-pmtiles-patterns.
source-layer and the tile schemaThe most common cause of a custom style rendering nothing against a working tile source is a source-layer mismatch.
A vector tile source contains named layers — transportation, water, landuse and so on — and every style layer that draws from it must name one exactly:
{
"id": "roads",
"type": "line",
"source": "basemap",
"source-layer": "transportation"
}
source-layer is required for vector sources and must match the tile schema exactly. A typo or a name from a different schema produces no error and no output — the layer simply draws nothing.
Find the real names in the TileJSON. For vector sources, the TileJSON vector_layers field lists each available source-layer, its attribute fields, and its zoom range. This is the authoritative reference when it is present — TileJSON 3.0 requires it for vector tilesets, but 2.x documents predate it and providers are inconsistent about supplying it. Its absence does not mean there is no schema: identify the schema by name (below) and work from its published layer list. If you use a provider's pre-built style URL, the schema is already matched for you; the mismatch only appears when you write your own layers.
When building a custom style you need to know the tile schema — the source-layer names and their properties. Common schemas:
transportation, water, landuse, poi. The largest ecosystem of community styles targets this schema.earth, water, roads, places; optimized for serverless delivery. Published layer list: docs.protomaps.com/basemaps/layers.Each of these publishes its layer list as documentation (see References). None carries a machine-readable version marker, so checking a schema means re-reading the page; nothing can poll it for changes.
When generating tiles with Planetiler or tippecanoe, the output embeds TileJSON metadata in the MBTiles or PMTiles file. Tile servers like Martin read this metadata and expose it as a TileJSON endpoint automatically.
Layers are drawn bottom-to-top in the order they appear in the style. map.addLayer() with no second argument appends the layer above everything, including street names — which is why a data overlay added this way hides the basemap's labels. The fix is to pass the ID of the first symbol layer as addLayer's second argument, found programmatically rather than hardcoded (road-label and friends are schema-specific and break the moment you change basemaps). A raster layer added after vector layers obscures them for the same reason.
For the injection pattern in full, and the canonical layer order for a style built from scratch, see maplibre-cartography.
glyphs and spriteTwo style-root properties supply the assets that symbol layers draw with:
glyphs — URL template for font stacks: "glyphs": "https://example.com/fonts/{fontstack}/{range}.pbf"sprite — base URL for the sprite sheet and metadata, serving both .json and .png: "sprite": "https://example.com/sprites/basic"Pre-built style URLs from hosted providers include their own. When building a custom style or self-hosting, you must supply them.
The two fail differently when absent, and the difference is what makes a symptom readable backwards to a cause. Since GL JS 5.11.0 an absent glyphs does not remove text: MapLibre renders it in a local system font instead, so the symptom is text in the wrong face, not missing text. Reach for glyphs when the labels are there but wrong, not when they are absent entirely. An absent sprite logs a console warning for each missing icon (Image "<id>" could not be loaded) and renders none; map.hasImage(id) returns false for each. A sprite URL that fails to load also logs an error.
For the fallback's mechanism and its limits (it is GL JS only; Native still needs served PBFs), font stacks, self-hosting versus generating, and script coverage, see maplibre-fonts-glyphs.
tileSize and naming trapsTwo raster-specific pitfalls that wire without error but render wrong or against the wrong assumption:
tileSize defaults to 512, but classic OSM tiles are 256, so a 256px source left at the default renders a zoom level off (imagery and labels) with no error or warning. tile.openstreetmap.org and other classic slippy-map servers serve 256px tiles. When you recommend tileSize: 256, state that consequence before or with the fix:
{
"type": "raster",
"tiles": ["https://tile.openstreetmap.org/{z}/{x}/{y}.png"],
"tileSize": 256
}
A raster endpoint's name is not its type. An endpoint named "hillshade," "terrain," or similar is not necessarily a raster-dem source. raster-dem requires the tiles to encode elevation as pixel-packed RGB (Mapbox or Terrarium encoding) in PNG or WebP — TileJSON's encoding field, when present, names which. A tile format that can't hold that encoding (JPEG, for instance) with no encoding field is ordinary raster imagery whatever the endpoint is named — a "hillshade" endpoint is often a pre-rendered hillshade image, not raw elevation data for MapLibre to shade client-side. Check the tile format and any encoding field before treating a name as evidence of raster-dem.
promoteId is usually how it gets onesetFeatureState and the feature-state expression key on a feature's id — a top-level member of the feature object, not a value inside properties. A source whose features have no id gives setFeatureState nothing to attach to, so it fails silently: no console error, the paint expression never fires, and getFeatureState returns empty.
Set promoteId to the property you already key on. It tells MapLibre to use that property as the feature id, and it is the right answer whenever the identifier lives in properties:
map.addSource('parcels', {
type: 'geojson',
data: parcels,
promoteId: 'parcel_id'
});
map.setFeatureState({ source: 'parcels', id: 'APN-1234' }, { hover: true });
For a vector source, promoteId is either a property name applied across all source-layers, or an object of the form {<sourceLayer>: <propertyName>}.[9]
Do not reach for generateId or a hand-written id when a business key exists. Both look like fixes and both fail this case:
generateId: true assigns ids by index in the features array, overwriting any existing values.[9] The ids are not stable across a setData that reorders, filters, or appends, so state silently attaches to the wrong feature after an update.id works only for integers: without promoteId, a feature's id "must be an integer or a string that can be cast to an integer."[9] A key like APN-1234 is accepted and then never matches. With promoteId the value may be any primitive.If your tiles, glyphs, or sprites are on a different origin, the server must send CORS headers (Access-Control-Allow-Origin). Otherwise the browser blocks the requests and the map is blank or missing labels.
Hosted providers handle CORS for you. For self-hosted servers or static storage, configure CORS on the server or CDN. Range-request sources (PMTiles) additionally need Access-Control-Allow-Headers: Range.
Work down this list for a map with one of the symptoms above — they overlap heavily. It is not an appendix to, or a template for, an answer about anything else.
| Symptom | Check first |
|---|---|
| Nothing at all, network shows failed requests | CORS headers; the tile URL itself (404s in the network tab) |
| Nothing at all, network shows 200s | source-layer names against the TileJSON vector_layers |
| Tiles appear then vanish as you zoom in | Missing zoom range on a hand-wired tiles source; use url instead |
| Tiles render, text in the wrong font | glyphs missing, or its URL failing to load |
| Tiles render, no text at all | No text-field on any symbol layer; or GL JS older than 5.11 |
| Tiles render, no icons | Missing sprite at the style root |
| Data draws but hides labels | Layer order; insert before the first symbol layer |
| Vector source draws nothing, raster fine | source-layer missing entirely — it is required for vector sources |
| Raster tiles render a zoom level off | Missing tileSize: 256 on a classic 256px source (default is 512) |
setFeatureState does nothing, no error | Features have no id; set promoteId to the identifying property |
pmtiles:// protocol and PMTiles-specific source setup.sprite URL forms, loading multiple sheets, self-hosting sprite assets, and route shields.vector_layers required for vector tilesetspromoteId, generateId, and feature-state — Style Specification: sources and expressionsThis skill is a snapshot. Where a primary source contradicts it — the References above, MapLibre's current documentation, or what MapLibre does when you run it — that source wins. Follow it, then report the disagreement, citing the source and your MapLibre version: editing your installed copy helps no one else and is overwritten on the next update.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/maplibre-agent-skills:maplibre-source-wiringfrom maplibre-agent-skills
npx claudepluginhub maplibre/maplibre-agent-skills --plugin maplibre-agent-skills10 skills in this plugin
/maplibre-cartographyCartographic principles for MapLibre GL JS — label and symbol legibility on imagery vs. vector basemaps, figure-ground for point icons, styling vector roads over aerial imagery, visual hierarchy, layer ordering for data injection, and accessibility. Use when styling a map, choosing text or symbol colors, making markers or roads readable on satellite/aerial imagery, or ordering layers correctly./maplibre-fonts-glyphsConfiguring fonts and glyphs for MapLibre GL JS and MapLibre Native — the style's `glyphs` URL, self-hosting or generating font PBFs, the GL JS local-font fallback (omitted `glyphs` or a failed glyph fetch), the `font-faces` property both SDKs read, and CJK, right-to-left and Devanagari script handling. Use when text labels aren't rendering in the intended font, setting up a glyphs server, choosing between self-hosting and generating font PBFs, or handling non-Latin scripts./maplibre-mapbox-migrationMigrating from Mapbox GL JS to MapLibre GL JS — package, import and namespace changes, removing the access token, replacing mapbox:// styles, tile sources, plugin equivalents (draw, geocoder, directions, compare), and Mapbox v2-only APIs such as setFog and the free camera. Use when moving an existing Mapbox map to MapLibre, or when a migrated map shows a blank map, a mapbox:// or 401 error, or a missing Mapbox method or plugin./maplibre-pmtiles-patternsServerless vector and raster tiles with PMTiles for MapLibre GL JS — single-file format, HTTP range requests, hosting on S3/R2/GitHub Pages, generating with Planetiler or tippecanoe, and the pmtiles protocol. Use when you need no tile server or want to host tiles from static storage./maplibre-skill-authoringHow to turn a working session into a MapLibre agent skill — you researched something MapLibre's docs did not cover, got it wrong before you got it right, shipped it, and the session is about to end. Covers what to capture while the context is still live, how to separate the durable claim from the project it came from, and where to hand it off. Use at the end of a MapLibre task that took real research, or when asked to capture one as a skill./maplibre-sprites-iconsSprites and icon images for MapLibre GL JS — choosing a `Marker`, a sprite, or `addImage`; the `sprite` base URL and its `{id, url}` array form for several sheets; self-hosting and building sprites; runtime images, SVGs included, with `addImage`; finding a missing icon with the console warning and `hasImage`; and route shields that render as bare numbers. Use when deciding how to put icons on a map, when a symbol layer's icons never appear, when adding your own icons to a style whose sprite you do not control, or when shields are missing their badge.Other plugins' skills for the same job