参考:Adding multiple Custom Icon in Folium
需要注意的是,如果多个点,每次都要创建一次,因此放在for循环内部!
代码:
import folium
m=folium.Map(location=[20, 0],
zoom_start=2,
#tiles='https://mt.google.com/vt/lyrs=s&x={x}&y={y}&z={z}',
tiles='https://mt.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',
attr='default')
for i in range(len(df_new)):
icon_url = './biolab_icon4.png' # icon path
icon = folium.features.CustomIcon(icon_url, icon_size=(30, 30)) # create icon feature
folium.Marker(
[float(df_new.loc[i, "Latitude"]), float(df_new.loc[i, "Longitude"])],
icon=icon, # add icon
popup=folium.Popup(df_new.loc[i, "Name"], max_width=1000),
tooltip=df_new.loc[i, "Name"]).add_to(m)
m
显示效果:
标签:loc,786,df,float,marker,new,folium,icon From: https://www.cnblogs.com/alex-bn-lee/p/16972109.html