folium 自定义地图图块

gge*_*oge 5 leaflet stamen-maps folium

我想将此地图图块图层添加到我的地图 - Stamen toner-background。正如我在文档中阅读的那样,我需要在地图的tiles 属性中简单地提供自定义网址

mapa = folium.Map(width=1000, height=700, zoom_start=5.5,
              location=[52.5, 19], tiles='http://maps.stamen.com/toner-background/embed#6/{x}/{z}', attr="toner-bcg")
Run Code Online (Sandbox Code Playgroud)

它加载但没有显示任何内容。

我真的不知道这种归因是如何运作的,我应该怎么做。我喜欢这种瓷砖,因为它就像雄蕊调色剂,但没有国名,这使我的地图更漂亮。

Fer*_*l G 4

这是您的幸运日,雄蕊设计内置于 Folium 中。您应该运行以下代码:

mapa = folium.Map(width=1000, height=700, zoom_start=5.5,
              location=[52.5, 19], tiles='Stamen Toner')
Run Code Online (Sandbox Code Playgroud)

这应该可以解决问题。

您的代码无法正常工作的原因是您没有使用正确的 URL 模板。格式是此处指定的:

http://tile.stamen.com/toner/ {z}/{x}/{y}.png
http://tile.stamen.com/terrain/ {z}/{x}/{y}.jpg
http://tile.stamen.com/watercolor/ {z}/{x}/{y}.jpg

代码如下所示:

mapa = folium.Map(width=1000, height=700, zoom_start=5.5,
              location=[52.5, 19], tiles='http://tile.stamen.com/toner/{z}/{x}/{y}.png ')
Run Code Online (Sandbox Code Playgroud)