Providing MapLibre-compatible style JSON from openstreetmap-tile-server

[Previous: Self-hosting maps on my laptop]

In the previous post I showed how to run OSM tile server stack locally.

Now I’ve managed to connect a MapLibre GL JS front end to my local tile server and it’s showing maps!

(It’s running inside Element Web, the awesome Matrix messenger I am working on. NOTE: this is a very, very early prototype!)

In the previous post I ran a docker run command to launch the tile server.

This time, I had to create a file style.json:

  "version": 8,
  "sources": {
    "localsource": {
      "type": "raster",
      "tiles": [
      "tileSize": 256,
      "attribution": "Maps Copyright 2018 <a href=\"\">Geofabrik GmbH</a> and <a href=\"\">OpenStreetMap Contributors</a>"
  "layers": [
      "id": "locallayer",
      "source": "localsource",
      "type": "raster"

and then I launched the tile server with that file available in the document root:

docker run \
    -p 8080:80 \
    -v $PWD/style.json:/var/www/html/style.json \
    -v openstreetmap-data:/var/lib/postgresql/12/main \
    -v openstreetmap-rendered-tiles:/var/lib/mod_tile \
    -e THREADS=24 \
    -e ALLOW_CORS=enabled \
    -d overv/openstreetmap-tile-server:1.3.10 \

Now I can point my MapLibre GL JS at that style file with code something like this: = new maplibregl.Map({
    container: my_container,
    style: "",
    center: [0, 0],
    zoom: 13,

Very excited to be drawing maps without any requests leaving my machine!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.