maplibre-pmtiles-patterns
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.
What this skill does
# 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](https://github.com/maptiler/tileserver-gl) or [Martin](https://maplibre.org/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**](https://protomaps.com) 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 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'));
```
**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-tile-sources](../maplibre-tile-sources/SKILL.md)).
**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](https://docs.protomaps.com/pmtiles/maplibre) (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](https://docs.protomaps.com/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 sRelated in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.