This gist describes how to download a map for a custom region and serve it on a website.
It uses the Protomaps Basemap but the same workflow can be used with OpenMapTiles or Shortbread.
The download links are:
- OpenMapTiles: https://tile.openstreetmap.jp/static/
- Shortbread: https://blog.geofabrik.de/index.php/2023/03/30/experimental-vector-tiles-on-download-server/
- Protomaps: https://maps.protomaps.com/builds/
Define the outline of the region you want to have a map of with https://geojson.io.
With this website you can draw a polygon and get the geojson of it.
Copy the geojson from the right panel to a files called outline.geojson
.
The pmtiles
command line tool allows you to download a map extract for the region defined in outline.geojson
.
The pmtiles
tool is distributed as a binary executable on the github releases at https://github.com/protomaps/go-pmtiles/releases
Download the pmtiles
tool for your machine:
With the pmtiles
tool we can now download the pmtiles file for the region defined in outline.geojson
:
pmtiles extract https://build.protomaps.com/20240721.pmtiles protomaps.pmtiles --region outline.geojson
You might need to change the date to the current date...
Now download the files below index.html
and style.json
to the folder where you have the outline.geojson
and protomaps.pmtiles
file.
Serve the files with a http server that supports range requests, e.g., npx serve --debug . -p 3000 --cors
.
Open a web browser at http://localhost:3000/
and you find your map: