systemed / mod_mbtiles

Serve tiles with Apache directly from an .mbtiles file
19 stars 2 forks source link

config info #1

Open schierkolk opened 1 year ago

schierkolk commented 1 year ago

What configuration file do I update and where in the file do I update?

systemed commented 1 year ago

Whatever the Apache config file is for the virtual host (site) you're deploying. For example, /etc/apache2/sites-available/my.tile.server.com.conf.

You would typically put the directives within the <Directory> unit of that file.

schierkolk commented 1 year ago

Thank you for getting back to me. I am not getting any data to come through nor am I getting any errors. Would it be possible to get am example .conf to make sure I am doing this correctly?

systemed commented 1 year ago

Mine looks like this (with paths/domains obfuscated):

<VirtualHost *:80>
    DocumentRoot "/srv/tile.my.server"

    ServerName tile.my.server

    <Directory "/srv/tile.my.server">
        allow from all
        Options None
        Require all granted

        Header set Access-Control-Allow-Origin "*"

        MbtilesEnabled true
        MbtilesAdd dem /data/relief/dem.mbtiles
        MbtilesAdd contours /data/relief/contours.mbtiles
        MbtilesAdd vt /data/vector_tiles/vt.mbtiles
    </Directory>
</VirtualHost>

Most of this is just standard Apache. Only the four Mbtiles lines are new.

Don't forget you need to restart Apache once you've changed a config file.

resiliencetheatre commented 1 year ago

Can you provide reference how you use vt/ in your web page to display map?

systemed commented 1 year ago

Using the Maplibre GL JS library.

resiliencetheatre commented 1 year ago

Yes, I use same - but have hard time understanding how you define layers from mod_mbtiles ? Example would be great!

systemed commented 1 year ago

Not quite sure what you mean? You don't define any layers in mod_mbtiles - it simply serves out the .mbtiles file (containing vector tiles) that you point it at. Layers are defined when you create the vector tiles with other software, such as tilemaker.

resiliencetheatre commented 1 year ago

This is how I've defined my tileserver-gl provided mbtiles for my style.json:

"sources": { "openmaptiles": { "type": "vector", "url": "http://localhost:8080/data/v3.json" } },

But somehow I am not able to get mod_mbtiles URL here to provide anything useful?

systemed commented 1 year ago

mod_mbtiles just serves vector tiles from an mbtiles. Nothing else. It doesn't generate or serve tilejson documents or anything like that.

You either need to specify the location of your Apache virtual server (running mod_mbtiles) in the .json file you're pointing to above, or just put it in directly:

  "sources":{
    "openmaptiles":{
      "type":"vector",
      "tiles":["https://my.tile.server/directory/{z}/{x}/{y}.pbf"],
      "minzoom":0,
      "maxzoom":14,
      "attribution":"Base map © OpenStreetMap"
    }
  }