<< All versions

Skill v1.0.0

currentAutomated scan100/100
kendrick-oppong/geoskills/maplibre-vector-tile-styling
──Details
PublishedOctober 25, 2026 at 01:32 AM
Content Hashsha256:86e2c26b919f6f02...
Git SHA77bd91343bcb
──Files
Files (1 file, 4.6 KB)
SKILL.md4.6 KBactive
SKILL.md · 77 lines · 4.6 KB

version: "1.0.0" name: maplibre-vector-tile-styling description: Use when writing or debugging a MapLibre/Mapbox style spec — layer ordering, data-driven expressions, zoom-dependent styling, sprite/glyph setup, and integrating MapLibre into a React or Angular component.


MapLibre GL Vector Tile Styling

When to use this skill

  • Writing or debugging a MapLibre/Mapbox-compatible style JSON
  • "My layer isn't showing" / "styling doesn't change with zoom" / layer ordering issues
  • Wiring MapLibre into a React component (react-map-gl) or an Angular component

Core concepts

  • Style spec structure: sources (where data comes from — vector tiles, GeoJSON, raster) → layers (how each source is drawn, referencing a source and optionally source-layer for vector tiles) → paint/layout properties per layer.
  • Layer order = paint order: layers later in the array draw on top — a common bug source is a fill layer accidentally covering a line/label layer below it in z-order despite looking "correct" in the source JSON.
  • Expressions (["interpolate", ["linear"], ["zoom"], ...], ["match", ["get", "category"], ...]) drive data-driven and zoom-dependent styling — this is the idiomatic way to do choropleth coloring, zoom-based line width, etc., entirely on the GPU without re-rendering tiles.
  • `source-layer` must match the actual layer name inside the vector tile (set at tile-generation time, e.g. by tippecanoe) — a mismatch here is the most common "nothing renders" bug and produces no error.

Checklist

  • [ ] Does every vector-tile layer reference the correct source-layer name exactly as baked into the tiles?
  • [ ] Is layer order intentional — polygons below lines below points below labels, generally?
  • [ ] Are data-driven styles using expression syntax rather than manually re-styling on every zoomend/data event (expressions run on the GPU and are far cheaper)?
  • [ ] For choropleths, is the color scale using interpolate/step bound to a real data property, with a legend that matches the same breakpoints?
  • [ ] Are custom fonts/icons registered via loadImage/sprite sheet before layers referencing them are added — referencing a missing image/glyph fails silently (icon doesn't render, no console error in older versions)?
  • [ ] In React: is the map instance created once (e.g., in a useEffect with an empty dependency array) and cleaned up on unmount, rather than re-created on every render?
  • [ ] In Angular: is the MapLibre instance held in a component field (not recreated in change detection cycles), with ngOnDestroy calling map.remove()?

Common pitfalls

  • `source-layer` mismatch: single most common "why isn't anything showing" bug with vector tiles — always verify against the actual tile's layer names (tippecanoe/tile inspector output), not assumed names.
  • Re-styling via imperative `setPaintProperty` calls on every state change instead of data-driven expressions bound once — creates React/Angular re-render thrash and defeats GPU-side styling.
  • Adding a layer before its source has finished loading (map.on('load', ...) not awaited) — causes intermittent "layer not found" errors that are hard to reproduce.
  • Z-fighting/label collisions from too many symbol layers competing for space — use layout: { 'symbol-avoid-edges': true } and collision-aware layer ordering rather than manually offsetting labels.
  • Mixing MapLibre and Mapbox style-spec versions: a style authored against Mapbox v3 spec may use properties MapLibre doesn't (yet) support, or vice versa — pin to one spec version and validate against it.

Reference snippets

javascript
map.addSource('buildings', {
type: 'vector',
tiles: ['https://cdn.example.com/tiles/{z}/{x}/{y}.pbf'],
minzoom: 0, maxzoom: 14,
});
map.addLayer({
id: 'buildings-fill',
type: 'fill',
source: 'buildings',
'source-layer': 'buildings', // must match the tile's internal layer name exactly
paint: {
'fill-color': [
'interpolate', ['linear'], ['get', 'height'],
0, '#f2f0f7', 50, '#6a51a3',
],
'fill-opacity': ['interpolate', ['linear'], ['zoom'], 10, 0, 12, 0.8],
},
});
typescript
// React (react-map-gl / MapLibre)
useEffect(() => {
const map = new maplibregl.Map({ container: ref.current!, style, center, zoom });
return () => map.remove();
}, []); // instantiate once

Related skills

  • vector-tile-pipeline — generating the tiles being styled
  • webgis-engine-selection — whether MapLibre is the right engine choice
  • cartographic-design-for-web-maps — the design theory behind color/symbology choices
All versions