Notes · · 1 min read
One file instead of a tile server
A PMTiles archive holds a whole map in one file that a browser can read in pieces, straight from ordinary storage.
A tile server answers one request per tile, so serving a map used to mean running a server. PMTiles, a single file archive format from the Protomaps project, removes that step: the file sits on plain storage, and the map app reads only the bytes it needs with HTTP range requests.
The file starts with a fixed header of 127 bytes, which says where the directory is. The directory maps tile addresses, the z, x and y of each tile, to positions in the file. Tiles are numbered along a Hilbert curve, which keeps tiles that are close on the map close in the file, so a view of one area becomes a few large reads instead of many small ones.
Repetition is stored once. Open sea or empty land produces thousands of identical tiles; the directory points them all at the same bytes, and runs of them take one entry.
For an online map this means no tile server to maintain. For offline work we still choose per device: PMTiles where the app reads it directly, MBTiles where the app expects a database, from the same source data either way.