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.24k stars 639 forks source link

Attach sprites to configuration #541

Open qubiack opened 3 years ago

qubiack commented 3 years ago

In the documentation, I found information that we can add some sprites files but I can't attach them directly to style. I would like to have access to sprites with links like http://localhost:4800/styles/dionisos/sprite so for example: http://localhost:4800/styles/dionisos/sprite.json

It's possible to attach files directly to style? How can I do that?

{
  "options": {
    "paths": {
      "root": "/data",
      "fonts": "fonts",
      "styles": "styles",
      "sprites": "sprites",
      "mbtiles": "mbtiles"
    }
  },
  "styles": {
    "dioniso": {
      "style": "dioniso/style.json"
    }
  },
  "data": {
    "v3": {
      "mbtiles": "zurich.mbtiles"
    }
  }
}
amorfinv commented 3 years ago

Unsure if this is the issue, but your config.json file has the style name 'dioniso' and your url path has 'dionisios' (with an 's' at the end). If this is the issue can you share how you use config.json because I haven't found a way to do it. In fact, I am still unsure how to use config.json to get the tileserver to start with a style different than basic-preview. I am using make start-tileserver from openmaptiles to create a docker container. Have you been able to do this?

However, I have been able to add my own styles, sprites and glyphs using this method.

I pretty much just copy the sprite sheet into the server and then just restart the server.

copy sprite sheets: docker cp sprite.json [container_id]:/app/node_modules/tileserver-gl-styles/sprites/dioniso/sprite.json

I think you need to also add sprite.png, sprite@2x.json, and sprite@2x.png.

After this just restart the docker container. Also make sure your sprite path is correct in style.json. If you put it in the same path that I did, then you just need to have "sprite": "sprites/custom_night/sprite".

It should now be accessible at http://localhost:8080/styles/dionisos/sprite.json. or on whatever port you are using.

-Andres

qubiack commented 3 years ago

I have 4 files - sprites - 2 png and 2 JSON files, but it's I suppose impossible to configure it as expected. The documentation for Tileserver-gl is really poor in this aspect - there is some information about sprites but no information on how we define access for them or any dir structure to show an example.

amorfinv commented 3 years ago

Yeah, the documentation is not very clear how it should be done. However, I think the method from #530 should work. I have been able to add my own sprites in this way. How does your style.json look?