使用 folium 将文件夹链接添加到 python 地理编码器

Add folder links into python geocoder with folium

我想用单独的地理文件扫描存档数据(列出的 dics)并将文件路径作为 link 添加到弹出窗口中:

locations_map = Map()
locations_map.add_child(
   Marker(location = [47.981300, 7.842700],
                     icon = folium.Icon(color = 'blue')));

file_dict = [{'file' : '/data/test 6/', 'go' : 'one', 'loc' : '47.981367, 7.842787'},
             {'file' : '/data/TEST4a/', 'go' : 'two', 'loc' : '47.981767, 7.842097'}]

for i in pd.Series(file_dict):
    name = i['go']
    file_dir = i['file']
    locations = i['loc'].split(",")
    folium.features.RegularPolygonMarker(location = [locations[0], locations[1]],
                                        tooltip = name,
                                        popup = "Name:" + name 
                                         + "Location: " + ("<a href=file_dir>open</a>")
                                         ).add_to(locations_map)

在浏览器中打开:

locations_map.save("locations_map.html")
webbrowser.open("locations_map.html", new=2);

输出给我 /MyMagnumMint/Archive-Mapping/file_dir,而不是 /MyMagnumMint/Archive-Mapping/data/test 6//MyMagnumMint/Archive-Mapping/data/TEST4a/

我尝试使用不同的引号 ("<a href='file_dir'>open</a>") 和 RegularPolygonMarkers 的“https”功能。

已解决:

for i in pd.Series(file_dict):
     name = i['go']
     file_dir = i['file']
     hyperlink_format = '<a href="{link}">{text}</a>'
     hyperlink = hyperlink_format.format(link=directory, text='open')
     locations = i['loc'].split(",")
     folium.features.RegularPolygonMarker(location = [locations[0], locations[1]],
                                    tooltip = name,
                                    popup = "Name:" + name 
                                     + "Location: " + hyperlink
                                     ).add_to(locations_map)

感谢这个post