Skip to content

geohierarchy.maps.maplibre.pmtiles_meta

PMTiles v3 header (zoom range, bounds) read locally, so a MapLibre page can declare each vector source as a tile template with its own bounds and zooms instead of a pmtiles:// TileJSON URL.

Why: MapLibre fetches the TileJSON (the archive header) of every url source as soon as the source is added, visible or not. A nationwide page with thousands of chunk sources (one per state and level, ~4,000 voting-district chunks) then reads thousands of headers at start-up. A tiles: ["pmtiles://<file>/{z}/{x}/{y}"] source with bounds / minzoom / maxzoom is not touched until a tile inside its bounds and zoom range is needed (the pmtiles protocol reads the header then, once).

read_header(path)

{"minzoom", "maxzoom", "bounds": [w, s, e, n]} of a PMTiles v3 file, or None when it is not one (missing / older version).

Parameters:

Name Type Description Default
path

Path of the .pmtiles file.

required

lazy_source(url_path, file_path, maxzoom=None)

The source fields for a lazily read archive: tiles template (+ minzoom / maxzoom / bounds from its header), or None if unreadable.

Parameters:

Name Type Description Default
url_path str

Path of the archive as the page requests it (relative URL, no pmtiles://).

required
file_path

The archive on disk (its header is read).

required
maxzoom Optional[int]

Optional cap on the source's maximum zoom.

None