maplibre-cartography
Cartographic principles for MapLibre GL JS — label and symbol legibility on imagery vs. vector basemaps, figure-ground for point…
Serverless 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
$ npx -y skills add maplibre/maplibre-agent-skills --skill maplibre-pmtiles-patterns --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/maplibre-pmtiles-patternsContext preview
The summary Claude sees to decide when to auto-load this skill.
Serverless 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
name: maplibre-pmtiles-patterns description: Serverless 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. status: verified
PMTiles is a single-file format for vector or raster map tiles. You host one (or a few) files on any static host; MapLibre requests byte ranges over HTTP. No tile server, no dynamic backend. This skill covers when to use PMTiles, how to generate and host them, and how to connect them to MapLibre GL JS.
**When to prefer PMTiles over a traditional tile server:**
**When to prefer a tile server (e.g. tileserver-gl, Martin):**
MapLibre does not speak PMTiles natively. You use the **PMTiles** library to add a protocol handler so that a `pmtiles://` (or `https://` to a .pmtiles file) source works.
**Install:**
npm install pmtiles
**Register the protocol and use in a style:**
import * as pmtiles from 'pmtiles';
import * as maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
// Add PMTiles protocol so sources can reference .pmtiles URLs
const protocol = new pmtiles.Protocol();
maplibregl.addProtocol('pmtiles', protocol.tile);
const map = new maplibregl.Map({
container: 'map',
style: {
version: 8,
sources: {
tiles: {
type: 'vector',
url: 'pmtiles://https://example.com/data.pmtiles'
}
},
layers: [
{
id: 'background',
type: 'background',
paint: { 'background-color': '#f8f4f0' }
},
{
id: 'water',
type: 'fill',
source: 'tiles',
'source-layer': 'water',
paint: { 'fill-color': '#a0c8f0' }
}
// add more layers as needed — each uses the same source, different 'source-layer'
]
},
center: [0, 0],
zoom: 2
});
// Optional: remove protocol on map teardown
// map.on('remove', () => maplibregl.removeProtocol('pmtiles'));**`addProtocol` changed in MapLibre GL JS 4.0.0.** The v3 `(params, callback)` signature is gone — the 4.0.0 changelog entry reads "Changes `addProtocol` to be promise-based without the usage of callbacks and cancelable". A handler is now `async (params, abortController)` and must resolve to **an object with a `data` property**: `{data, cacheControl?, expires?}`. Resolving to a bare `ArrayBuffer`, `Blob`, `Response` or `Uint8Array` is not the contract — MapLibre reads `.data` off whatever the handler resolves with, so a bare buffer reads as no data at all and an `arrayBuffer` request is filled with an empty `ArrayBuffer(0)`: the tile comes back blank instead of erroring. Register the handler on the module — `maplibregl.addProtocol(...)`, or the named `addProtocol` import — once, before the first map is constructed: the protocol registry is global, so one registration covers every map on the page.
// ❌ v3 — on v4+ the second argument is an AbortController, so callback(...) throws,
// and the returned {cancel} has no data: the tile comes back blank
maplibregl.addProtocol('custom', (params, callbCurated guidance for AI assistants building MapLibre applications — covering ecosystem and open-source best practices. Agent skills are markdown files that AI coding assistants read as context.
Cartographic principles for MapLibre GL JS — label and symbol legibility on imagery vs. vector basemaps, figure-ground for point…
Configuring fonts and glyphs for MapLibre GL JS and MapLibre Native — the style's `glyphs` URL, self-hosting or generating font…
Migrating from Mapbox GL JS to MapLibre GL JS — package and import changes, removing the access token, choosing tile sources,…
The step-by-step procedure for running this repo's Promptfoo evals with a generator and a judge over provider APIs. Use when…
How to turn a working session into a MapLibre agent skill — you researched something MapLibre's docs did not cover, got it wrong…
Getting a MapLibre GL JS source to actually render — TileJSON `url` versus hand-wired `tiles` templates, matching `source-layer`…