openstreetmaptilemillmapnik

Switch styles on an OpenStreetMap server using Mapnik, PostGIS etc


I have created an OpenStreetMap server using this guide: switch to osm it's very good and works like a charm. I have also been able to add a new theme using TileMill and osm-brigth

However, I now want to be able to switch between two themes, osm-bright and osm-night. Is this an apache question or is there a way to modify mapnik to be able to get a parameter from for example openlayers to switch between these two themes?

Gratefull for any advice.


Solution

    1. Install "OSM Night" style like the first one into a separate directory, download all required files.
    2. Produce XML out of MML with carto -l project.mml > osm-night.xml, like you probably did with osm-bright.
    3. Edit /etc/renderd.conf adding a second style section, like for osm-bright, but with names and paths to osm-night.
    4. Restart renderd and apache2.

    After that you will have two set of tiles generated: e.g. /osm-bright/{z}/{x}/{y}.png and /osm-night/{z}/{x}/{y}.png. Add both of them as tile layers to your OpenLayers page, and add a layer switcher. (I use Leaflet and not sure how it's done in OL).