Logo van Maplibre Pmtiles Patterns

Maplibre Pmtiles Patterns

Organisatie
maplibre
maplibre-pmtiles-patterns

Serverloze vector- en rastertiles met PMTiles voor MapLibre GL JS — bestandsformaat met één bestand, HTTP-rangeverzoeken, hosting op S3/R2/GitHub Pages, genereren met Planetiler of tippecanoe en het pmtiles-protocol. Gebruik dit wanneer je geen tileserver nodig hebt of tiles vanuit statische opslag wilt hosten.

Overzicht

Uitgevermaplibre
Repositorymaplibre-agent-skills
Skillnaammaplibre-pmtiles-patterns
Sterren
148
Forks
10
Meegeleverde bestanden
Alleen instructies
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Compleet zonder extra bestanden

    Alles wat het model nodig heeft, staat in de instructies — geen extra bestanden om te synchroniseren.

  • Open source

    Gepubliceerd door maplibre op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Maplibre Pmtiles Patterns in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/maplibre/maplibre-agent-skills/tree/main/skills/maplibre-pmtiles-patterns
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/maplibre/maplibre-agent-skills.git /tmp/maplibre-agent-skills
mkdir -p .claude/skills
cp -r /tmp/maplibre-agent-skills/skills/maplibre-pmtiles-patterns .claude/skills/maplibre-pmtiles-patterns
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Maplibre Pmtiles Patterns in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Maplibre Pmtiles Patterns automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Maplibre Pmtiles Patterns niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

MapLibre PMTiles Patterns

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 Use This Skill

  • Hosting map tiles without running a tile server (S3, Cloudflare R2, GitHub Pages, etc.)
  • Building a fully static or serverless map stack
  • Serving large tile sets from a CDN with range requests
  • Generating PMTiles from OSM or other sources (Planetiler, tippecanoe)
  • Using Overture Maps or other single-file tile datasets with MapLibre

What PMTiles Is and Why It Matters

  • Vector and raster — PMTiles supports both. A file can contain vector layers (e.g. water, roads, POIs), raster imagery (PNG/JPEG), or raster-dem (elevation, e.g. Terrarium format for terrain). In the style you use type: 'vector', type: 'raster', or type: 'raster-dem' accordingly.
  • Single file per map — One .pmtiles file typically contains the full tile pyramid (all zoom levels) and all layers (vector or raster) in one archive. The format stores tiles in a compact layout (e.g. Hilbert curve) so the client can request only the byte ranges it needs. For very large coverage you may split by region into multiple files.
  • HTTP range requests — The client requests only the byte ranges it needs (e.g. one tile), so the server does not need to understand x/y/z. Any host that supports Range headers works.
  • Serving — You can serve directly from static storage (S3, R2, GitHub Pages, Netlify): the client uses range requests, so no tile server is required. Alternatively, tileserver-gl or Martin can serve PMTiles (from local paths, HTTP URLs, or S3), useful if you want one server that also provides styles, glyphs, or other sources.
  • Creating — You can get PMTiles by converting from MBTiles (PMTiles CLI) or by generating from source data (Planetiler, tippecanoe, GDAL, etc.). Alternatively, Protomaps is a provider where you can download pre-built PMTiles (e.g. global or regional basemaps) and serve them yourself, or create custom extracts via the PMTiles CLI—no need to generate from OSM yourself. Protomaps basemaps are built from OpenStreetMap data; OSM attribution is required in any map that uses them. See The PMTiles CLI and Generating PMTiles below.
  • Good for CDNs — Range requests cache well; put the file behind a CDN for fast global access.

When to prefer PMTiles over a traditional tile server:

  • You want zero server logic (static hosting only).
  • You have a bounded dataset (country, region, theme) that fits in one or a few files.
  • You want simple deployment and low ops (upload file, set cache headers, done).

When to prefer a tile server (e.g. tileserver-gl, Martin):

  • You need dynamic tiles from a database (PostGIS) or frequently updated data.
  • You have a very large global dataset and want to generate tiles on demand or by region only.

MapLibre Integration: The PMTiles Protocol

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:

bash
npm install pmtiles

Register the protocol and use in a style:

javascript
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.

js
// ❌ 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, callback) => {
  fetch(params.url)
    .then((r) => r.arrayBuffer())
    .then((buffer) => callback(null, buffer))
    .catch((error) => callback(error));
  return { cancel: () => {} };
});

// ✅ v4+ — async (params, abortController) resolving to {data}
maplibregl.addProtocol('custom', async (params, abortController) => {
  const response = await fetch(params.url, { signal: abortController.signal });
  if (!response.ok) throw new Error(`Tile fetch error: ${response.statusText}`);
  const buffer = await response.arrayBuffer();
  return { data: buffer }; // the {data} wrapper is required; a bare buffer is not
});

PMTiles users need no code change. new pmtiles.Protocol().tile is the library's v4 handler wrapped in its v3compat shim (pmtiles ≥ 3.0.0): it checks whether the second argument is an AbortController and adapts, so the single line maplibregl.addProtocol('pmtiles', protocol.tile) is correct on GL JS v3, v4, v5 and v6, and it already resolves to {data: Uint8Array, cacheControl, expires}. A project still on pmtiles 2.x has a callback-only tile and must upgrade the library along with MapLibre. The contract above is what you need when you write your own handler, or when a hand-rolled callback handler broke on the v4 upgrade.

Referencing layers: The style has one source (e.g. sources.tiles) pointing at the .pmtiles URL. Each layer in the layers array that draws from that file uses source: 'tiles' and "source-layer": "layerName", where layerName is the name of a vector layer inside the file (from whatever schema the tiles use). Add multiple style layers with different source-layer values to show roads, labels, etc. from the same file.

Important: The url can be pmtiles://https://... (protocol + HTTPS URL to the .pmtiles file). The library will fetch the file via range requests. Your style must still define glyphs and sprite if you use labels or icons (see maplibre-source-wiring).

Zoom range comes from the header — use url:, not tiles:. A PMTiles archive stores its own min/max zoom in the header. When you reference it with url: 'pmtiles://https://...', the protocol reads that header and hands MapLibre a TileJSON with the correct minzoom/maxzoom, so overzoom past the archive's max works automatically and you never set maxzoom by hand. If you instead hand-wire a tiles: ['pmtiles://.../{z}/{x}/{y}'] template, you bypass that header lookup. The protocol still serves the per-tile requests up to the archive's max — this is not a missing-handler or 404 problem — but MapLibre, given no zoom range, assumes maxzoom: 22 and keeps requesting zoom levels the archive doesn't contain, which come back empty (blank tiles for vector, nothing for raster) instead of overzooming. Always use url:.

❌ A source has exactly two tile-location properties: url and tiles. There is no tileset property in the MapLibre style spec, for vector, raster or raster-dem sources. If a zoom range is wrong, fix which of the two you used; don't reach for a third.

Raster and raster-dem: The same protocol works for raster PMTiles. Use a type: 'raster' source for imagery. For terrain/elevation, use a type: 'raster-dem' source with "encoding": "terrarium" (or "mapbox") so MapLibre can apply hillshade or 3D terrain; then reference it in the style’s terrain property. Example source:

json
"elevation": {
  "type": "raster-dem",
  "url": "pmtiles://https://example.com/elevation.pmtiles",
  "encoding": "terrarium"
}

Using PMTiles with React: Register the protocol once at application startup, not inside each component, so MapLibre has the handler before any map mounts. For example, call maplibregl.addProtocol('pmtiles', protocol.tile) in a root-level effect or when your map provider initializes. On unmount of the last map (or when the app tears down), call maplibregl.removeProtocol('pmtiles') to avoid leaks. See PMTiles for MapLibre GL (Protomaps) for a React-oriented setup.

Hosting PMTiles

Any host that serves the file and supports HTTP Range requests is suitable.

  • AWS S3 — Enable public read (or signed URLs); S3 supports Range. Set Cache-Control and optionally use CloudFront.
  • Cloudflare R2 — S3-compatible; enable public access or use signed URLs. Put behind Cloudflare for caching.
  • GitHub Pages — MapLibre GL JS can load tiles from a .pmtiles file in the same repo as long as the file size is under 100 MB.
  • Netlify / Vercel — Upload the .pmtiles file; static hosting typically supports Range. Check each provider’s file size limits.
  • Any static host — Ensure the server returns Accept-Ranges: bytes and responds correctly to Range headers.

CORS: Browsers will send cross-origin requests to the PMTiles URL. The host must send Access-Control-Allow-Origin: * (or your domain) and Access-Control-Allow-Headers: Range (or allow all). Otherwise MapLibre will fail to load tiles.

Cache headers: For better performance, set long cache for the .pmtiles file (e.g. Cache-Control: public, max-age=31536000 if the file is immutable). CDNs will cache range responses.

The PMTiles CLI

The pmtiles CLI is the official command-line tool for working with PMTiles (and MBTiles for conversion). It’s a single binary with no runtime dependencies—you download it and run it.

Why install and use it:

  • Convert MBTiles to PMTiles — Many tools (tippecanoe, GDAL, martin-cp) output MBTiles. One command turns any .mbtiles file into a .pmtiles file: pmtiles convert in.mbtiles out.pmtiles. This is often the simplest way to get PMTiles when your pipeline already produces MBTiles.
  • Inspect and verify archives — pmtiles show <file> prints header and metadata (bounds, zoom range, tile count). pmtiles verify <file> checks archive integrity. Useful for debugging or confirming a file before uploading.
  • Extract subsets — pmtiles extract creates a smaller .pmtiles file from an existing one (e.g. by bounding box or zoom range), so you can ship a region or a limited zoom band without regenerating from source.

❌ The subcommand list is closed — don't reach for a plausible-sounding verb. go-pmtiles ships exactly show, tile, verify, extract, merge, serve, convert, cluster, upload, edit and version. There is no info verb and no inspect verb, and nothing sets metadata from the command line except edit. To read an archive's header, bounds and zoom range, the command is pmtiles show; to check integrity, pmtiles verify.

Install: Download the binary for your OS/arch from GitHub Releases (go-pmtiles), or use Docker: protomaps/go-pmtiles.

What it does not do: The CLI only works with tile archives (MBTiles and PMTiles). It does not read GeoJSON, Shapefile, OSM, or other source formats. To create PMTiles from those, use a tool that generates tiles (see Generating PMTiles below) and, if that tool outputs MBTiles, run pmtiles convert to get PMTiles.

Generating PMTiles

Two paths: (1) Convert — The PMTiles CLI converts MBTiles ↔ PMTiles only; it does not read GeoJSON, Shapefile, OSM, or other source formats. (2) Generate from source data — Tools like tippecanoe, Planetiler and ogr2ogr via GDAL read from many file types or databases and produce vector tiles (PMTiles or MBTiles). If they output MBTiles, use pmtiles convert to get PMTiles.

PMTiles CLI (convert only: MBTiles ↔ PMTiles)

See The PMTiles CLI above for why to install it and other commands (show, verify, extract). To convert MBTiles to PMTiles:

bash
pmtiles convert input.mbtiles output.pmtiles

The following tools generate tiles from source data (GeoJSON, OSM, Shapefile, PostGIS, etc.). They output PMTiles or MBTiles; if MBTiles, run pmtiles convert to get PMTiles.

Planetiler (OSM / OpenMapTiles schema)

Planetiler reads OpenStreetMap (or other sources) and outputs PMTiles or MBTiles in the OpenMapTiles schema.

bash
# Example: build a PMTiles file for a region (e.g. from a .osm.pbf download)
java -jar planetiler.jar --area=monaco --output=monaco.pmtiles

See Planetiler docs for area names, custom sources, and schema options. Output is a single .pmtiles file you can upload to S3/R2/static host.

tippecanoe

tippecanoe generates vector tiles from source formats: GeoJSON, FlatGeobuf, CSV. From v2.17 onward it can output PMTiles directly (-o output.pmtiles). You can also output MBTiles and convert with pmtiles convert.

bash
# Direct PMTiles output (v2.17+)
tippecanoe -zg -o output.pmtiles input.geojson
# Or MBTiles then convert: tippecanoe -o output.mbtiles -z 14 input.geojson && pmtiles convert output.mbtiles output.pmtiles

ogr2ogr (GDAL)

GDAL’s ogr2ogr generates tiles from many geospatial formats (Shapefile, PostGIS, GeoJSON, etc.) and can write MBTiles or PMTiles (GDAL 3.8+). Best for smaller datasets; tippecanoe is more efficient for large vector tile sets.

Raster and raster-dem PMTiles

PMTiles supports raster tiles (PNG/JPEG, e.g. satellite or pre-rendered imagery) and raster-dem (elevation/terrain, e.g. Terrarium or Mapbox encoding). Use tools that produce raster or raster-dem PMTiles; the same protocol and hosting apply. In the style use type: 'raster' for imagery or type: 'raster-dem' with "encoding": "terrarium" (or "mapbox") for terrain—see MapLibre Integration above for an example.

Overture Maps

Overture Maps publishes global open map data. Some providers distribute Overture-derived data as PMTiles (e.g. for buildings, places, transportation). You can also build PMTiles from Overture data with Planetiler or other pipelines. Use the PMTiles URL in your MapLibre style as above.

Performance Tips

  • CDN — Serve the .pmtiles file from a CDN (CloudFront, Cloudflare) so range requests are fast globally.
  • Compression — PMTiles stores tiles compressed; the library handles decompression. Ensure the server does not double-compress (e.g. gzip) the whole file in a way that breaks range requests.
  • Multiple files — For very large coverage, split by region into several .pmtiles files and switch the source URL or use multiple sources by bounds.
  • Caching — Set strong cache headers on the file; the browser and CDN will cache range responses.

Related Skills

  • maplibre-tile-sources — Choosing between GeoJSON and tiles for a dataset.
  • maplibre-source-wiring — TileJSON, source-layer, glyphs and sprite, CORS.
  • maplibre-style-patterns — Layer and paint configuration for vector sources (including PMTiles-backed sources). (Not yet in repo.)

References


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.

Veelgestelde vragen

Wat doet de AI-skill Maplibre Pmtiles Patterns?

Serverloze vector- en rastertiles met PMTiles voor MapLibre GL JS — bestandsformaat met één bestand, HTTP-rangeverzoeken, hosting op S3/R2/GitHub Pages, genereren met Planetiler of tippecanoe en het pmtiles-protocol. Gebruik dit wanneer je geen tileserver nodig hebt of tiles vanuit statische opslag wilt hosten.

Waarom Maplibre Pmtiles Patterns gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Maplibre Pmtiles Patterns bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Maplibre Pmtiles Patterns in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/maplibre/maplibre-agent-skills/tree/main/skills/maplibre-pmtiles-patterns. TypingMind leest het bestand SKILL.md en installeert het als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Maplibre Pmtiles Patterns gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Maplibre Pmtiles Patterns gebruiken?

Zoveel als je wilt. Je kunt Maplibre Pmtiles Patterns gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Maplibre Pmtiles Patterns gratis?

Deze skill is door maplibre op GitHub gepubliceerd. Bekijk de repository voor de licentievoorwaarden. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇