maptiler / tileserver-gl

Vector and raster maps with GL styles. Server side rendering by MapLibre GL Native. Map tile server for MapLibre GL JS, Android, iOS, Leaflet, OpenLayers, GIS via WMTS, etc.
https://tileserver.readthedocs.io/en/latest/
Other
2.21k stars 634 forks source link

Complete guide: From starting docker to running custom style #226

Open rrrnld opened 6 years ago

rrrnld commented 6 years ago

Hi! I just tried getting the app up and running via docker on a local machine with a custom extract and it worked flawlessly, really cool! I was surprised how easy it was. When I however tried to get it up and running with a custom style I struggled a bit until I figured that it's probably faster to just ask for help.

I started with creating a config.json and tried to replicate the default styles at first; when I copied it from the docs it gave me various errors about missing folders. I then tried to build the standard styles by running node publish.js (I commented out the last bit that's running npm publish) and copied the resulting folders styles and fonts to my tilebox-gl folder, after which sprites were missing. I removed the sprites directory in config.json, resulting in this config.json:

{
  "options": {
    "paths": {
      "root": "",
      "fonts": "fonts",
      "styles": "styles",
      "mbtiles": "mbtiles"
    },
    "domains": [
      "localhost:8080",
      "127.0.0.1:8080"
    ],
    "formatQuality": {
      "jpeg": 80,
      "webp": 90
    },
    "maxScaleFactor": 3,
    "maxSize": 2048,
    "pbfAlias": "pbf",
    "serveAllFonts": false,
    "serveStaticMaps": true
  },
  "styles": {
    "basic": {
      "style": "klokantech-basic/style.json",
      "tilejson": {
        "type": "overlay",
        "bounds": [8.44806, 47.32023, 8.62537, 47.43468]
      }
    }
  },
  "data": {
    "berlin-vector": {
      "mbtiles": "2017-07-03_germany_brandenburg.mbtiles"
    }
  }
}

This gave me the following result:

$ docker run --rm -it -v (pwd):/data -p 8080:80 --name tileserver-gl klokantech/tileserver-gl:latest -c config.json 
Waiting 3 seconds for xvfb to start...
Starting tileserver-gl v2.2.0
Using specified config file from config.json
Starting server
ERROR: data "v3" not found!

And now I'm here. My folder structure looks like this:

$ tree -L 2
.
├── README.md
├── config.json
├── fonts
│   ├── Open\ Sans\ Bold
│   ├── Open\ Sans\ Italic
│   ├── Open\ Sans\ Regular
│   └── Open\ Sans\ Semibold
├── mbtiles
│   └── 2017-07-03_germany_brandenburg.mbtiles
├── styles
│   ├── klokantech-basic
│   └── osm-bright
└── tileserver-gl-styles
    ├── LICENSE.md
    ├── README.md
    ├── fonts
    ├── package.json
    ├── publish.js
    ├── styles
    └── styles_modules

What my original goal was: Serving raster tiles for either https://github.com/openmaptiles/positron-gl-style or, preferably https://github.com/openmaptiles/mapbox-studio-light.tm2. I figure the mapbox studio light style has the wrong format, so I aimed for positron first. What exactly are the steps to configure the docker image to serve positron raster and vector files?

Thanks a lot for any help.

klokan commented 6 years ago

The easiest is to launch OpenMapTiles Server (which has a web wizard for the config): https://openmaptiles.com/server/

dbauszus-glx commented 6 years ago

I went through the wizard and selected an export json from the maputnik style editor. But advancing to publish the style file which I selected was not shown as an additional style. Is adding styles a restriction of the evaluation version the OpenMapTiles Server? Or it might be that something is not right with the setup that files cannot be uploaded but I didn't see any error messages in the log of the OpenMapTiles Server.

klokan commented 6 years ago

Could you please retry with the latest version of OpenMapTiles Server - it should run. If not - please provide us with link to the JSON file - so we can reproduce the problem on our side and fix it.

nijs9 commented 6 years ago

I'm running into the same issue. I've setup OpenMapTiles Server and uploaded a custom style in the advanced option with 'styles' when running setup. I tried adding the Klokantech Terrain style (not modified). I can select the json file from the file picker, but when proceeding with setup, this style is not added to the list of available styles. I used this style:

http://editor.openmaptiles.org/?style=https://rawgit.com/openmaptiles/klokantech-terrain-gl-style/master/style.json#12.24/47.3718/8.5481

laapsaap commented 6 years ago

ffs I followed tutorials and setup mod_tile and renderd. For what?

asitemade4u commented 6 years ago

Hi @klokan , same error here using the docker image of tileserver GL. Just for the record, I extensively use Docker for my developments. I work on a Linux Ubuntu 16.04 LTS machine. Here are:

suavedev commented 6 years ago

@heyarne Try to rename "berlin-vector" to "v3" in your config file. Also look at the positron style json file and check that it is referencing it in the sources field: "sources": { "openmaptiles": { "type": "vector", "url": "mbtiles://{v3}" } @asitemade4u Could you check this?

jbelien commented 4 years ago

Hello everyone,

I'm struggling to find out how to add custom styles to OpenMapTiles Server. This it what I run:

docker run --rm -it -v $(pwd)/data:/data -p 8080:80 --name tileserver-gl maptiler/tileserver-gl:latest -c config.json

The -c parameter doesn't seem to be taken into account, here is what the terminal returns:

Starting Xvfb on display 99
xdpyinfo:  unable to open display ":99".
xdpyinfo:  unable to open display ":99".

Starting tileserver-gl v3.0.0
No MBTiles specified, using tiles.mbtiles
[INFO] Automatically creating config file for tiles.mbtiles
[INFO] Only a basic preview style will be used.
[INFO] See documentation to learn how to create config.json file.
Run with --verbose to see the config file here.
Starting server
Listening at http://[::]:80/
Startup complete

Any idea what I'm doing wrong ? Thanks!

jbelien commented 4 years ago

Well, it was simplier than expected. I just had to put the config.json file in my data folder (no need for -c parameter). 👌

tommasodelorenzo commented 2 years ago

I am running on a related problem when running

docker run --name tileserver-gl -it -v $(pwd)/data:/data -p 8085:80 maptiler/tileserver-gl:latest -c my_config.json

The terminal output seems promising

Starting tileserver-gl v3.1.1
Using specified config file from my_config.json
Starting server
Listening at http://[::]:8080/
Startup complete

But I get a "this site can't be reached" at localhost:8085. Here is the structure of my_config.json:

{
    "options": {
      "paths": {
        "root": "/data",
        "styles": "styles",
        "mbtiles": ""
      },
      "formatEncoding": {
        "png": 6,
        "jpeg": 80,
        "webp": 90
      }
    },
    "styles": {
      "my_style": {
        "style": "my_style.json"
      }
    },
    "data": {
      "malta-vector": {
        "mbtiles": "tiles.mbtiles"
      }
    }
  }

The my_stile.json file is a slight modification of the osm-liberty style done with maputnik, and I also later modified the sources key as:

"sources": {
    "openmaptiles": {
      "type": "vector",
      "url": "mbtiles://{malta-vector}"
    },
    "natural_earth_shaded_relief": {
      "maxzoom": 6,
      "tileSize": 256,
      "tiles": [
        "https://klokantech.github.io/naturalearthtiles/tiles/natural_earth_2_shaded_relief.raster/{z}/{x}/{y}.png"
      ],
      "type": "raster"
    }
  },

The $(pwd)/data structure is the following

.
├── malta.bbox
├── malta.osm.pbf
├── my_config.json
├── quickstart_checklist.chk
├── styles
│   └── kc_style.json
└── tiles.mbtiles

What am I doing wrong? Weirdly, I get a "this site can't be reached" at localhost:8085 also when running

docker run --name tileserver-gl -it -v $(pwd)/data:/data -p 8085:80 maptiler/tileserver-gl:latest -V

while works perfectly without the verbose option.