如何将Geojson几何图形绑定到Folium中的HTML弹出窗口

时间:2020-11-03 09:34:01

标签: html data-binding popup geojson folium

您好,这是我的第一篇文章(显然是newB)-最终目标是能够单击多边形,并从geojson文件(gdf)生成poup。

我知道答案会很明显,但是我似乎无法弄清楚。

....................

gdf=geopandas.read_file("D:\ALK_gis\Map\Folium\\UL.geojson" ) #create data frame

lot=list(gdf["CLOT"]) #create list of data from GDF
proj=list(gdf["Project"])#create list of data from GDF
covid=list(gdf["COVid"])#create list of data from GDF
geom=list(gdf["geometry"])#create list of data from GDF

fg1=folium.FeatureGroup(name="cadastre") #create a feature group for pop up not sure if this is correct

for (lot,po,uid) in zip(lot,proj,covid): #bind instances and ref in HTML
    pg = folium.Html( f'''<!DOCTYPE html>
    <html><head></head> 
    <Body style="background-color:grey;width: 302px">
    <h1 style="color:rgb(236, 77, 77);background-color: oldlace;bottom:0px;padding-bottom:0px;margin-bottom: 0px; margin-top: 5px; margin-left:2px;width: 298px;">Lot Details</h1>
    <table style="margin-left:0px;">
        <tbody>
            <tr><td style= background-color:oldlace;width:100px> <span style= columns:#343434;3434>CovID</span> </td>
                <td style= background-color:oldlace;width:200px> <span style= color:#343434> {uid}</span> </tr> 
            <tr><td style= background-color:oldlace;width:100px> <span style= columns:#343434;3434>Lot#</span> </td>
                <td style= background-color:oldlace;width:200px> <span style= color:#343434> {lot}</span> </tr>
            <tr><td style= background-color:oldlace;width:100px> <span style= columns:#343434;3434>Project</span> </td>
                <td style= background-color:oldlace;width:200px> <span style= color:#343434> {po}</span> </tr> 
        </tbody>
    </table></Body>''', script=True) 

    pup1=folium.Popup(pg, max_width=2650)
    #not sure if marker is the way to go here
    # fg1.add_child(folium.Marker.(location=gdf["geometry"],popup=pup1)) 

#or bind it some how here 
folium.GeoJson(data=gdf["geometry"]).add_child(pup1).add_to(m)


m.save("Folium/folium.html")

我对HTML进行了排序,并弹出了ID在地图上的显示方式,但没有填充数据。我需要将数据绑定到几何图形(以蓝色表示)。

folium HTML popup

1 个答案:

答案 0 :(得分:0)

我的解决方案:

let q: <X as Iterator>::Item = ()