Create fully self-hosted Mapbox vector tiles with Nix using Tilemaker. All files are static served, thus can be used offline.
Uses data from Geofabrik to create vector tiles for Hessen (state in Germany).
Tiles will be displays using maplibre-gl at
127.0.0.1:8081/index.html
. Notice that files might display
incorrectly across rebuilds due to serving directly from the Nix
store. Files inside the Nix store have the same timestamps which cause
caching issues inside the browser.
nix run github:jmpunkt/nix-vector-tiles#demo-maptiler-basic-gl-style
Tiles will be displays using maplibre-gl at 127.0.0.1:8080
. Requires
Nginx, thus runs in a Qemu instance.
nix run github:jmpunkt/nix-vector-tiles#demo-nginx-maptiler-basic-gl-style
Currently (22-04-2023) Firefox does not display sprites correctly. It is best to use Chromium based browsers.
{buildTilesBundle, buildTilesMetadata, buildTiles, tilesStyles}: buildTilesBundle {
host = "http://127.0.0.1:8081";
metadataFn = tilesUrl:
buildTilesMetadata {
tileJson = {tiles = [tilesUrl];};
tiles = buildTiles {
name = "germany-hessen";
src = fetchGeofabrik {
continent = "europe";
country = "germany";
name = "hessen";
date = "230101";
sha256 = "sha256-sOoPtIEY4TxSm/p0MGc9LGzQtQmIafGH0IWbkby95K8=";
};
# renumber nodes for less memory consumption
renumber = true;
config = {settings.compress = "gzip";};
# compression is disabled by default
# config = {};
};
};
styleFn = tilesStyles.maptiler-basic-gl-style;
};
Here are some very short example configurations for Nginx. Notice
that ${bundle}
refers to a tile bundle derivation.
location /map/ {
alias ${bundle}/share/www/;
try_files $uri $uri/ =403;
location /map/tiles/data/ {
gunzip on;
gzip_static on;
gzip_proxied expired no-cache no-store private auth;
}
}
Notice that root
must be set to "${bundle}/share/www"
in the
Nginx config.
location / {
try_files $uri /index.html;
location /tiles/data/ {
gunzip on;
gzip_static on;
gzip_proxied expired no-cache no-store private auth;
}
}
- allow font to be combined
- package Maplibre-js
- fix (Roboto) fonts for osm-liberty