Cartographic principles for MapLibre GL JS: label/symbol legibility on imagery vs. vector basemaps, figure-ground for point icons, styling roads over aerial imagery, visual hierarchy, layer ordering for data injection, and contrast accessibility.
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.
MapLibre renders exactly what you describe in your style. This skill covers how to describe it well: choosing label colors for readability on any basemap, building a coherent visual hierarchy, and ordering style layers correctly. For font/glyph setup, see maplibre-fonts-glyphs; for sprites, icon sourcing, and route shields, see maplibre-sprites-icons.
text-color and text-halo-color, or point symbol/icon colors, for a new or migrated style — including cases where they read fine on a flat vector basemap but disappear or camouflage once the basemap is imagerysprite, icons, or route shields — see maplibre-sprites-icons; for glyphs, see maplibre-fonts-glyphsMapLibre places labels dynamically, so you cannot mask the background behind each label as you would on a static map. Instead, choose a text-halo-color that separates the label from every background it might land on, and a text-color that reads against the halo. On a single uniform basemap tone (flat light or dark vector), the halo can match that tone instead of contrasting it — the text itself does the contrasting against the basemap. Imagery has no single tone to match, so there the halo must contrast every possible background instead:
| Basemap type | Background | Recommended text color | Recommended halo |
|---|---|---|---|
| Light vector (streets, OpenFreeMap positron) | Pale/white | Dark (#333 or similar) | Light semi-transparent (rgba(255,255,255,0.8)) |
| Dark vector (dark-matter, navigation night) | Dark | White or near-white (#ffffff) | Dark semi-transparent (rgba(0,0,0,0.75)) |
| Satellite or aerial imagery (NAIP, Sentinel-2) | Unpredictable — bright crops, dark forests, urban rooftops | White (#ffffff) | Dark semi-transparent (rgba(0,0,0,0.75)) |
The most common mistake is a white halo with no transparency: unless the background is pure white, it disrupts the spatial connection between the label and the feature it labels — add transparency. The second is reusing a light-vector palette over imagery, where it fails on dark terrain, forests, and water. On imagery, always use white text and a dark semi-transparent halo ("text-color": "#ffffff", "text-halo-color": "rgba(0,0,0,0.75)", "text-halo-width": 1.2).
For tinted labels (parks, water, POIs), use a light tint of the semantic color (#c8f5cc parks, #a8d8ff water) rather than the dark saturated version: tints read against dark halos while keeping semantic meaning, where full-saturation colors contrast poorly at small sizes.
Wider halos increase legibility but add visual weight. Typical values:
| Context | text-halo-width |
|---|---|
| Body labels (city, town, village) | 0.8–1.5 |
| Country / continent (large text) | 1.5–2.0 |
| Small POI or peak labels | 0.8–1.2 |
| Water / park labels with colored text | 1.0–1.5 |
text-halo-width is in pixels relative to the text. The halo must not bleed into adjacent labels: keep it tight at small text sizes and add transparency.
Markers face the same figure-ground problem as labels, but with different tools. A colored icon on aerial imagery competes with an unpredictable, busy, desaturated photographic background.
icon-halo-color/icon-halo-width, exactly as you would halo a label — this only affects SDF sprite images (addImage(..., { sdf: true }) or a sprite built as SDF); a full-color raster icon has no halo paint property, so any edge treatment on it has to be baked into the artwork itself. A thin light halo reads against dark canopy and water; a darker edge holds against bright soil and rooftops. Keep it thin — a fat ring reads as a sticker — except for the one class of symbol meant to dominate the map (an emergency marker, the single most important thematic feature), where a heavier ring is the point.hillshade-illumination-direction (commonly NW, 315°) so the symbol sits in the same light as the terrain.SVG icons via addImage: when loading an SVG into a sprite image at runtime (fetch the SVG, decode it as an Image, then map.addImage), the SVG rasterizes at decode time, so linearGradient and feDropShadow filters bake in correctly.[1] Two gotchas: pad the viewBox so halos and shadows are not clipped at the icon edge, and keep width/height proportional to the viewBox or the glyph distorts. Use "icon-allow-overlap": true for dense point data.
A well-ordered hierarchy means the most important features dominate at the appropriate zoom level — for labels and for line/polygon data layers alike. For labels, MapLibre controls hierarchy through text size, font weight, letter spacing, contrast, and zoom-range visibility. The same tools apply to lines and polygons: line-width and fill saturation stand in for text size, and contrast against the basemap (a saturated line on a muted background, a muted fill on a busy one) does as much hierarchy work as size does — see Styling Vector Roads Over Imagery below for the line/polygon case in detail.
Text size should decrease as feature importance decreases. These stops are a starting point; adjust for your tile schema and zoom range:
| Label type | Base zoom | Max zoom | Size range (px) |
|---|---|---|---|
| Continent | 1 | 4 | 14–20 |
| Country | 2 | 7 | 11–17 |
| City | 7 | 11 | 14–24 |
| Town | 10 | 14 | 11–16 |
| Village / hamlet | 11 | 16 | 10–14 |
| Airport / POI | 10 | 16 | 12–14 |
| Peak / summit | 8 | 13 | 10–11 |
Points of interest (POI) labels should be visually lighter (smaller, thinner weight) than settlement labels at the same zoom. On an imagery map showing gentle terrain like rolling hills, keep peak labels smaller than airport labels — these are elevation markers, not dominant landmarks.
Use font weight to reinforce hierarchy via text-font (e.g. ["Noto Sans Bold"]): Bold for countries and capital cities, Regular for towns, cities, and most labels, Italic for water bodies, parks, and regions (a cartographic convention no longer always observed).
For compact two-line labels (e.g. a symbol character above a name), reduce text-line-height below 1.0 to avoid excessive spacing:
{
"text-field": "△\n{name:latin}",
"text-line-height": 0.9,
"text-max-width": 8
}
Values around 0.9 produce tight, readable two-line labels at small sizes. Do not go below ~0.8 or lines will overlap at standard font sizes.
"text-transform": "uppercase" for country and continent labels — a conventional cartographic practice"text-letter-spacing": 0.05–0.1 for region labels to spread them across a territoryVector road palettes from light-basemap styles (OSM Bright, OSM Liberty) are tuned to pop against pale paper, using high saturation, warm hues, and full opacity. Those same properties compete with the photo once the basemap is imagery. Treat the imagery as the subject and the roads as a reference overlay layered on top of it, not the other way around.
#f90, #fd4, #b06010) is the most common offender; replace fills with light greys and casings with a darker grey or a deep same-hue color.{
"line-color": ["interpolate", ["linear"], ["zoom"], 10, "#454545", 12, "#5a5a5a", 14, "#6e6e6e"]
}
Sprite setup, loading multiple sprite sheets, self-hosting sprite assets, building a sprite from SVGs, and diagnosing route shields live in maplibre-sprites-icons.
MapLibre renders style layers in the order they appear in the style's layers array — first item is drawn first (bottom), last is drawn last (top). Getting this wrong is the most common cause of data layers obscuring basemap labels.
When adding your own data to an existing basemap style at runtime, insert your data layers before the first symbol layer (find it with map.getStyle().layers.find((l) => l.type === 'symbol')?.id and pass it as the second argument of addLayer) so your geometry renders under labels. Without that argument the data layer goes above everything, including labels.
When building a style from scratch, follow this ordering bottom to top:
backgroundHillshade sits directly above raster imagery and below all vector layers, with sufficient transparency to allow the imagery to show through. If you add transparency to the imagery and layer it over the hillshade, the imagery will appear faded or washed out. Hillshade applied over vector layers will make line and fill colors look blotchy, blurry or muted.
MapLibre styles are rendered in the browser as a WebGL canvas. Accessibility considerations:
rgba(0,0,0,0.75) halo satisfies this for most backgrounds — check the combined text+halo color, not the text alone, with a tool like the WebAIM Contrast Checker.sprite base URL and {id, url} array form, self-hosting and building sprites, runtime images with addImage, and route shields.glyphs URL, self-hosting or generating font PBFs, the GL JS local-font fallback, MapLibre Native's font-faces, and non-Latin script support.source-layer, layer order, and CORS.This 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
10 skills in this plugin
/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-source-wiringGetting a MapLibre GL JS source to actually render — TileJSON `url` versus hand-wired `tiles` templates, matching `source-layer` names to the tile schema, layer order and inserting below labels, `promoteId` and the feature ids that feature state needs, and the CORS and glyph failures behind a blank map. Use when a source is configured but nothing is drawing, or when setFeatureState does nothing./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./maplibre-agent-skills:maplibre-cartographyfrom maplibre-agent-skills
npx claudepluginhub maplibre/maplibre-agent-skills --plugin maplibre-agent-skillsOther plugins' skills for the same job