javascript 如何自定义传单地图 CSS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19367776/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 15:19:57  来源:igfitidea点击:

How to Customize Leaflet Map CSS

javascriptmapsleaflet

提问by Jason Biondo

I'd like to change the style of my leaflet map. I'd like to make it look more like google maps default theme. Are there different css files that be referenced to style the map differently? Is there a theme repository anywhere?

我想更改传单地图的样式。我想让它看起来更像谷歌地图的默认主题。是否有不同的 css 文件被引用来以不同的方式设置地图样式?任何地方都有主题存储库吗?

回答by Josh

There is a plugin for Leaflet that has a whole bunch of different basemap tile sets available. It's called leaflet-providers. Some of them are really good.

Leaflet 有一个插件,它有一大堆不同的底图图块集可用。它被称为传单提供者。其中一些非常好。

There's another pluginthrough which you can get Google, Bing, and Yandex's tile sets (though not Google's customizable ones).

还有另一个插件,您可以通过它获得 Google、Bing 和 Yandex 的图块集(尽管不是 Google 的可定制图块)。

Finally, you can make your own custom tile set through Cloudmadeand load it in Leaflet. The first 500,000 tiles (each month) are free, but if you need more than that, you'll have to pay. In the basic Leaflet tutorial, they have the line:

最后,您可以通过Cloudmade制作自己的自定义贴集并将其加载到 Leaflet 中。前 500,000 块瓷砖(每月)是免费的,但如果您需要更多,则必须付费。在基本的传单教程中,他们有这样一行:

L.tileLayer('http://{s}.tile.cloudmade.com/API-key/997/256/{z}/{x}/{y}.png', {
    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery ? <a href="http://cloudmade.com">CloudMade</a>',
    maxZoom: 18
}).addTo(map);

You would modify the url with the details given in Cloudmade after you create your custom tile set.

创建自定义磁贴集后,您将使用 Cloudmade 中提供的详细信息修改 url。

回答by yarl

Leaflet is only library for displaying various maps. You probably use map from OpenStreetMap project, but if you want to create own map style you need to use specialized software like Mapbox's TileMill, set up database, download raw data, etc.

Leaflet 是唯一用于显示各种地图的库。您可能使用 OpenStreetMap 项目中的地图,但是如果您想创建自己的地图样式,则需要使用专门的软件,例如 Mapbox 的 TileMill,设置数据库,下载原始数据等。

Anyway, current rendering of OSM map is written in CartoCSS, you can find Github repo here.

无论如何,目前 OSM 地图的渲染是用 CartoCSS 编写的,你可以在这里找到 Github repo 。

You can find various map renderings ready to use on OpenStreetMap wiki.

您可以在OpenStreetMap wiki上找到各种可供使用的地图渲染。