首页 文章

提高值错误('Custom files must have an attribution')

提问于
浏览
1

这是我编写的用于在python中使用folium生成 Map 的源代码

import folium
map3 = folium.Map(location=[53.073635, 8.806422], zoom_start=15, 
tiles='Stream Terreain')

在 Map 中放置一些标记

folium.Marker(location=[53.073635, 8.806422], popup='Ich bin verloren', 
icon=folium.Icon(icon='cloud')).add_to(map3)

folium.Marker(location=[53.073600, 8.806400], popup='Hej, ich bin da', 
icon=folium.Icon(icon='cloud')).add_to(map3)

print(map3.save('test3.html'))

不幸的是,PyCharm给出了以下错误:

Connected to pydev debugger (build 182.4129.34 Traceback (most recent call last):  

File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1664, in <module> main() 

File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1658, in main globals = debugger.run(setup['file'], None, None, is_module) . 
File "/Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py", line 1068, in run pydev_imports.execfile(file, globals, locals)  # execute the script .

在execfile exec(compile(内容“\ n”,文件,'exec'),glob,loc)中输入文件“/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py”,第18行 .

File "/Users/kuldeep/PycharmProjects/webmap/webmap_2.py", line 2, in <module> map3 = folium.Map(location=[53.073635, 8.806422], zoom_start=15, tiles='Stream Terreain') . 

File "/Users/kuldeep/PycharmProjects/webmap/venv/lib/python3.7/site-packages/folium/folium.py", line 278, in __init__
subdomains=subdomains .

文件“/Users/kuldeep/PycharmProjects/webmap/venv/lib/python3.7/site-packages/folium/folium.py”,第349行,在add_tile_layer no_wrap = no_wrap中 .

File "/Users/kuldeep/PycharmProjects/webmap/venv/lib/python3.7/site-packages/folium/raster_layers.py", line 113, in __init__ . 

raise ValueError('Custom tiles must have an attribution.')

ValueError:自定义图块必须具有属性 .

使用退出代码1完成的流程引发ValueError('自定义切片必须具有归属 . ')ValueError:自定义切片必须具有归属 . 进程以退出代码1结束

1 回答

  • 0

    传递自定义切片时,始终需要指定 attr 参数 . 这可以是任何String,也可以是html标签 . 它旨在为任何提供瓷砖的人提供信贷 .

    例如,创建这样的 Map

    map = folium.Map(tiles="tiles/{z}/{x}/{y}.png", attr="<a href=https://endless-sky.github.io/>Endless Sky</a>")
    

    将生成一个带有可点击链接的页脚:
    enter image description here

相关问题