Protomaps Blog

PMTiles on More Platforms

The PMTiles format is a cloud-native way to visualize map data in the browser, directly from cloud storage. Browser decoding via the TypeScript implementation is ideal for most use cases, and accelerated deployment options run on AWS and Cloudflare.

Here’s some highlights of new platforms and integrations in 2024:

Style Editor

Maputnik is a visual editor for MapLibre Style JSON that’s been migrated to the MapLibre GitHub umbrella organization. It’s the most full-featured way to tweak colors and label appearance. An experimental fork of Maputnik adds PMTiles sources directly to the editor, so you can customize maps on cloud-hosted datasets without any server or proxy setup!

Try it at editor.protomaps.com.

OpenLayers

The ol-pmtiles library has reached major version 1.0. New features include TypeScript support and custom non-HTTP data sources, such as local files. This library can be bundled with your OpenLayers application to display both raster or vector tilesets using the built-in tile display classes.

See example page and code for OpenLayers vector tile integration.

AWS CloudFormation

PMtiles is designed to run on plain S3-like storage, and has an identical developer experience for small neighborhood maps, scaling up to 100GB+ planet archives. For websites with lots of traffic, it’s best to use PMTiels in conjunction with a CDN integration, like with AWS Lambda and Cloudfront, to serve edge-cached ZXY tiles to viewers, eliminating the overhead of client-side decoding.

Previously the method to accomplish this on AWS was to click in the console for IAM role setup, lambda function deployment and CloudFront configuration. This was too time-consuming and error-prone.

The automation options we considered were Terraform, CDK and CloudFormation. CloudFormation ended up being the simplest choice, since anyone access to the AWS console can one-click upload a single YAML and go straight from a private S3 bucket to CDN tiles - no CLI required!

Thanks to contributors Carlos Honrado for kicking this off and Charlie McGrady for reviewing this feature.

Google Cloud and Azure

Along with AWS and CLoudflare, two new platforms have support for serverless decoding: Google Cloud and Microsoft Azure. This is a perfect fit for projects already built on GCP or Azure and leveraging blob storage.

Both of these deployment methods use the go-pmtiles Docker image to run on a scale-to-zero container platform, either Cloud Run or Azure Container Apps. Most importantly, the authentication with private storage is built-in and doesn’t require manually managing credentials.

Check out the guides for accelerating PMTiles on Google Cloud and Microsoft Azure.

Server

There’s plenty of reasons not to use any of the major cloud providers - you might simply want to run a world map on a server in your basement, on an airplane, or on an affordable VPS.

The docs for running the pmtiles CLI have been revamped, with details on pmtiles serve and setting up CORS and remote or local archives. Serving tiles this way is great for development too; for production use it’s best behind a reverse proxy like Nginx or Caddy.

Caddy

Additionally there’s now a first-class Caddy plugin for PMTiles, so you don’t need to keep any separate process running, the PMTiles decoding is embedded directly into the webserver! Configuration is directly in the Caddyfile:

 handle_path /tiles/* {
    pmtiles_proxy {
      bucket https://mybucket.com
      cache_size 256
      public_url https://example.com/tiles
    }
  }

See the docs on downloading a build with the plugin.

Thanks to NLnet and Radically Open Security for funding a security audit of the go-pmtiles server implementation as part of the NGI Zero Core grant program.