The Spectrum Dispatch News

technology

Self-hosting map tiles becomes cheap and easy with Protomaps

PMTiles format allows developers to deploy world maps as single files, potentially cutting costs 100x compared to commercial APIs like Mapbox.

Self-hosting map tiles becomes cheap and easy with Protomaps

Protomaps offers a new approach to map hosting that makes self-hosting viable for projects that can’t afford commercial map APIs. The core technology is PMTiles, a tile format that works via HTTP Range requests and can be deployed as a single file to cloud storage.

Self-hosting map tiles becomes cheap and easy with Protomaps

According to the source, commercial map APIs become prohibitively expensive once a project gains traffic. Mapbox, for instance, charges $5 per 1,000 map loads after the free tier is exhausted. PMTiles circumvents this by allowing developers to host maps independently using a CDN that supports Range requests.

The format is extremely portable. For CDNs with proper caching support, deployment requires only uploading the file to storage. For CDNs like Cloudflare that don’t natively support Range request caching, edge functions can translate traditional URL paths into Range requests.

Getting started is straightforward. Developers can download pre-built daily world maps or use a CLI to extract specific regions or zoom levels, creating smaller files tailored to their needs.

Bunny.net is highlighted as a cost-effective CDN option. The service supports HTTP Range requests, doesn’t collect personal data by default, and offers regional pricing—$0.01/GB for bandwidth to Europe and North America, with storage ranging from $0.01/GB/month to $0.055/GB/month depending on replication levels.

In practical terms, storing the 139GB world map with continent-wide replication costs about $5/month. A typical map interaction—loading Europe and zooming into a city—transmits roughly 5MB, costing approximately $0.00005. Over 1,000 map loads at that rate, costs could reach $0.05/1k—potentially 100x cheaper than Mapbox’s flat fee per visit.

The deployment process involves creating a storage zone with S3 compatibility, uploading the PMTiles file using tools like rclone, and configuring a pull zone. Security considerations include setting CORS restrictions to prevent unauthorized embedding and implementing download speed limits to avoid unexpected CDN bills.

Once deployed, maps can be embedded in websites using MapLibre GL by installing the pmtiles npm package and configuring the protocol and style according to official documentation.

Key facts

  • PMTiles format deploys as a single file accessible via HTTP Range requests
  • Bunny.net storage costs approximately $5/month for the full 139GB world map with continental replication
  • Potential per-visit costs of $0.05/1k map loads, potentially 100x cheaper than Mapbox
  • Pre-built daily world maps available for download, or custom extracts possible via CLI
  • MapLibre GL can embed the self-hosted tiles using the pmtiles npm package

Sources

← All posts