Protomaps Blog

Serverless Maps - Now Open Source

Accelerating Maps

Last year I described 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 the option of a content delivery network in front to accelerate 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: On AWS, response times average 100 ms for cache hits, 200 ms for misses. Cloudflare is significantly slower, but is improving as Cloudflare’s R2 offering matures.

Used in Production

Felt uses Protomaps with a CDN to serve user uploaded tilesets created with their open source tile generator, Tippecanoe.

OpenInfraMap uses the Protomaps Cloudflare integration to store and visualize rarely seen infrastructure from the OpenStreetMap dataset.

The Washington Post uses the Protomaps integration with AWS Lambda and Cloudfront to affordably power interactive data stories.

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. Here’s two free example datasets to try with your own install:

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

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.

Finally, if you’d just like to use the Protomaps-hosted deployment - it happens to run on Cloudflare - you can register for an API key. It’s free for non-commercial use, and commercial use is available to our GitHub Sponsors.

Happy mapping!