Search code examples
openstreetmap

Step by step instruction to run offline OpenStreetMaps


I'm trying to run offline version of OpenStreetMaps on my server.

I have an ASP.NET MVC app which displays OSM map. So far I run the quick start example from OpenLayers.

var map = new ol.Map({
    target: 'map',
    layers: [
        new ol.layer.Tile({
            source: new ol.source.OSM()
        })
    ],
    view: new ol.View({
        center: ol.proj.fromLonLat([
            37.41, 
             8.82
        ]),
        zoom: 4
    })
});

The thing is I need everything offline. I already downloaded planet-latest.osm.bz2 file, but I'm confused what are next steps.

I read I have to render tiles now, from osm file, right? I tried to use Mapnik/Maperetive to achieve this but it didn't go well. I also don't know how to connect all there things together.

@EDIT1 Do I have to render all tiles before use(approx. 20TB) or can I render tiles on demand (when someone will use map)?


Solution

  • I'll just clarify a couple different bits of terminology for you:

    • OpenStreetMap provide raw data of where roads, buildings, sea, etc. are
    • Mapnik is one of many tile servers
    • Tile Servers require raw data, and tile styles and generate images (usually)
    • Tile Styles are usually XML, you can generate these using CartoCSS and tools like TileMill
    • CartoCSS is similar to web CSS, but modified slightly to make more sense in the context of mapping
    • TileMill is one of many tools for writing and previewing CartoCSS

    The information above may not be necessary for you, because Open Tile Server has some sensible defaults and is probably the best place for you to look: https://opentileserver.org/