folium自定义地图图块

时间:2018-01-18 10:02:32

标签: leaflet folium stamen-maps

我想将此地图图块图层添加到我的地图 - Stamen toner-background。 正如我在文档中看到的,我需要在map

的tiles属性中简单地给出自定义url
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")

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

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

2 个答案:

答案 0 :(得分:1)

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

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

这应该可以解决问题。

您的代码无法正常工作的原因是您没有使用正确的网址模板。格式是指定的here

  

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 ')

答案 1 :(得分:0)

为改善费尔南多的答案,以下代码对我有用:

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 ', 
    attr="toner-bcg") # <-- note this
相关问题