Skip to content

Files

This branch is 2 commits ahead of, 43 commits behind protomaps/PMTiles:main.

js

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Sep 2, 2024
Sep 18, 2024
Feb 1, 2024
Mar 11, 2023
Jul 25, 2024
Jun 8, 2024
Sep 18, 2024
Jan 29, 2024
Sep 18, 2024
Jul 25, 2024
Jul 25, 2024
Nov 22, 2022
Jan 29, 2024

PMTiles for Browsers + NodeJS

See the JavaScript API docs

the PMTiles package can be included via script tag or ES6 module:

 <script src="https://unpkg.com/pmtiles@<VERSION>/dist/pmtiles.js"></script>

All the PMTiles exports are available under the global pmtiles variable e.g. pmtiles.PMTiles.

As an ES6 module: npm add pmtiles

import { PMTiles } from "pmtiles";

Leaflet: Raster tileset

Example of a raster PMTiles archive displayed in Leaflet:

import { PMTiles, leafletRasterLayer } from "pmtiles";
const p = new PMTiles('example.pmtiles')
leafletRasterLayer(p,{attribution:'© <a href="https://openstreetmap.org">OpenStreetMap</a>'}).addTo(map)

Live example | Code

Leaflet: Vector tileset

See protomaps-leaflet

MapLibre GL JS

Example of a PMTiles archive displayed in MapLibre GL JS:

 import { Protocol } from "pmtiles";
let protocol = new Protocol();
maplibregl.addProtocol("pmtiles",protocol.tile);
var style = {
"version": 8,
"sources": {
    "example_source": {
        "type": "vector",
        "url": "pmtiles://https://example.com/example.pmtiles",
        "attribution": '© <a href="https://openstreetmap.org">OpenStreetMap</a>'
    ...

Live example | Code

CORS

See the Protomaps Docs on Cloud Storage for uploading and configuring CORS for Cloudflare R2, Amazon S3, Google Cloud Storage and more.