Skip to content

Serverless Maps, Now Open Source

A few months ago I made a post about Protomaps Mantle, a commercial solution for self hosting planet-scale maps without running any servers. It's built on top of the open, cloud optimized PMTiles format, and adds a content delivery network in front to accelerate the delivery of map tiles to users anywhere in the world.

The code components of Mantle are now open source, under the same permissive licenses as the rest of the Protomaps software stack.

It's also been renamed: you can find it all at the serverless/ directory of the PMTiles repository, and get started with the docs at the new Protomaps Documentation site: CDN Integration.

A summary of features:

  • AWS Lambda and Cloudflare Workers functions for turning Z/X/Y URLs into PMTiles range requests to private storage buckets. Under 10kb compressed, with copy-and-paste deployment.

  • Simple, 20-minute setup guides on installing in your own AWS or Cloudflare account.

  • Tested in production at scale: Response times average 100 ms for cache hits, 200 ms for misses. It's been put through its paces by sites from Felt to OpenInfraMap.

Cost Comparison

A web application with 50,000 map loads using the Google Maps API will cost $350 per month.

A similar amount of traffic running through a Protomaps CDN install on Cloudflare, with an average of 20 tiles per session, costs fifty cents in Cloudflare Workers request fees.

Free Datasets

Protomaps-on-CDN enables serving any tiled data at scale - vector map tiles, raster tiles, or even RGB-encoded terrain data, all from a single serverless function. To demonstrate this, I'm releasing two free planet-scale datasets.

Vector Tiles (zooms 0-10)

Live Example Page

Link to download the dataset

A global vector tile dataset based on OpenStreetMap data. The organization of layers and tags is described at Basemap Layers, and open source styles are provided for Leaflet as well as MapLibre GL vector rendering.

The vector basemap's cartographic design is licensed as CC0 to maximize interoperability between frontend libraries and alternative datasets. It's based on OpenStreetMap data only, so you can do anything you'd like with the data, subject to the ODbL Produced Work attribution requrements.

Terrain RGB

Live Example page

Link to download the dataset

A global terrain RGB dataset, packaged from the Mapzen Joerd project. This is designed to work with MapLibre GL JS for global hillshading.

See the Joerd README for attribution requirements.

Copy these datasets!

You can hotlink directly to these datasets, because they're stored in public buckets on Cloudflare R2 and include Access-Control-Allow-Origin: * headers. But be aware that these URLs might change in the future.

A solution is to copy the PMTiles files to your own S3 or R2 bucket, so they'll last forever, under your own control, and at minimal cost. Unlike a map SaaS, you can cache and remix these datasets however you like.