这是我编写的用python中的大叶草生成地图的源代码
import folium
map3 = folium.Map(location=[53.073635, 8.806422], zoom_start=15,
tiles='Stream Terreain')
在地图上放置一些标记
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 .
文件” /Applications/PyCharm.app/Contents/helpers/pydev/_pydev_imps/_pydev_execfile.py”,第18行,位于execfile exec(compile(contents +“ \ n”,file,'exec'),glob,loc )。
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
答案 0 :(得分:0)
传递自定义图块时,始终需要指定attr
参数。这可以是任何字符串,也可以是html标记。旨在向提供贴砖的人致谢。
例如,创建这样的地图
map = folium.Map(tiles="tiles/{z}/{x}/{y}.png", attr="<a href=https://endless-sky.github.io/>Endless Sky</a>")
答案 1 :(得分:0)
尝试以下方法:
map3 = folium.Map(location=[53.073635, 8.806422], zoom_start=15, tiles='Stamen Terrain')
结果为:
("Stream Terreain" -> "Stamen Terrain")