Search code examples
javascriptopenlayersopenmaptiles

How do I use different themes for open street maps in open layers?


I have a map application with custom interactive layers, but I want to use the dark theme from this. I'm using playing around on jsfiddle and I just can't seen to get the dark theme to work. I tried this:

      new TileLayer({
        source: new TileJSON({
          url: 'https://raw.githubusercontent.com/openmaptiles/dark-matter-gl-style/master/style.json'
        })
      })

I'm using classic apache and php. I have no clue about npm and webpack.


Solution

  • The style.json is only a Mapbox Style Specification, not the Data as TileJSON itself.

    You can use Mapbox Style Specifications for Vector Tile Layers like the OSM by using ol-mapbox-style. There is also some information about this issue on openmaptiles, where you found the theme.