Python folium - only last record is shown on the map

32 views Asked by At

I am fetching data from the .csv file, but I don't know why just only the last file is visible on my map.

The code is like here:

df = pd.read_csv("sur_geo.csv")
su = MarkerCluster(name="Surveyors").add_to(m)

su1 = plugins.FeatureGroupSubGroup(su, "Build Manager PAYE")
m.add_child(su1)
su2 = plugins.FeatureGroupSubGroup(su, "Supervisor PAYE")
m.add_child(su2)
su3 = plugins.FeatureGroupSubGroup(su, "Build Manager - Contractor")
m.add_child(su3)
su4 = plugins.FeatureGroupSubGroup(su, "Supervisor - Contractor")
m.add_child(su4)
su5 = plugins.FeatureGroupSubGroup(su, "Engineer")
m.add_child(su5)
for i,row in df.iterrows():
lat =df.at[i, 'lat']
lng = df.at[i, 'lng']
nm = df.at[i, 'name']
sp = df.at[i, 'title']
sk = df.at[i, 'skillset']

popup = str(sp)

if sp == "Build Manager PAYE":
    folium.Marker(location=[lat,lng], popup=popup, icon = folium.Icon(color='red', 
icon='glyphicon-calendar', icon_color='blue')).add_to(su1)
elif  sp == "Supervisor PAYE":
    folium.Marker(location=[lat,lng], popup=popup, icon = folium.Icon(color='red', 
 icon='glyphicon-calendar', icon_color='red')).add_to(su2)
elif  sp == "Build Manager - Contractor":
    folium.Marker(location=[lat,lng], popup=popup, icon = folium.Icon(color='red', 
 icon='glyphicon-calendar', icon_color='green')).add_to(su3)
 elif  sp == "Supervisor - Contractor":
    folium.Marker(location=[lat,lng], popup=popup, icon = folium.Icon(color='red', 
 icon='glyphicon-calendar', icon_color='black')).add_to(su4)
 else:
    folium.Marker(location=[lat,lng], popup=popup, icon = folium.Icon(color='white', 
 icon='house', prefix='fa', icon_color='green')).add_to(su5)

csv file is correct, what is wrong with the file then?

0

There are 0 answers