简体   繁体   English

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

[英]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 .我有一个带有自定义交互层的 map 应用程序,但我想使用来自this的深色主题。 I'm using playing around on jsfiddle and I just can't seen to get the dark theme to work.在 jsfiddle 上玩,我只是看不到让黑暗主题工作。 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.我正在使用经典的 apache 和 php。 I have no clue about npm and webpack.我不知道 npm 和 webpack。

The style.json is only a Mapbox Style Specification, not the Data as TileJSON itself. style.json只是一个 Mapbox 样式规范,而不是 TileJSON 本身的数据。

You can use Mapbox Style Specifications for Vector Tile Layers like the OSM by using ol-mapbox-style .您可以通过使用ol-mapbox-style为矢量切片图层(如 OSM)使用 Mapbox 样式规范。 There is also some information about this issue on openmaptiles, where you found the theme.在您找到主题的 openmaptiles 上也有一些关于此问题的信息。

We are the authors of OpenMapTiles project and the repos you are linking.我们是 OpenMapTiles 项目和您链接的存储库的作者。

If you need to use the dark-matter-gl style - the easiest is to go to https://cloud.maptiler.com/maps/darkmatter/ , create a free account and copy&paste the sample viewer provided on this website.如果您需要使用 dark-matter-gl 样式 - 最简单的方法是将 go 到https://cloud.maptiler.com/maps/darkmatter/创建一个免费帐户并复制并粘贴此网站上提供的示例查看器。

This gives you free hosting and the style into your webpage - with a viewer of your choice, including OpenLayers.这为您提供了免费托管和网页样式 - 使用您选择的查看器,包括 OpenLayers。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM