如何在开放图层中为开放街道地图使用不同的主题?

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

我有一个带有自定义交互图层的地图应用程序,但我想使用 this. I'm using playing around on jsfiddle 中的深色主题,但我无法让深色主题发挥作用。我试过这个:

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

我正在使用经典的 Apache 和 php。我对 npm 和 webpack 一无所知。

style.json只是一个 Mapbox 样式规范,而不是 TileJSON 本身的数据。

您可以通过使用 ol-mapbox-style. There is also some information about this issue on openmaptiles, where you found the theme.

像 OSM 一样对矢量切片图层使用 Mapbox 样式规范

我们是 OpenMapTiles 项目和您正在链接的存储库的作者。

如果您需要使用 dark-matter-gl 样式 - 最简单的方法是转到 https://cloud.maptiler.com/maps/darkmatter/,创建一个免费帐户并复制并粘贴本网站提供的示例查看器。

这为您提供了免费托管和网页样式 - 使用您选择的查看器,包括 OpenLayers。