Beautify Icon does not work when used in a for loop
Hi
I am using BeautifyIcon to create a star shaped marker.
Issue I'm facing is: When I run the below code the , it runs as expected and plots a star mark at required Lat Lon
m = folium.Map([45.5, -122], zoom_start=3)
icon_star = plugins.BeautifyIcon(icon="star",text_color='#b3334f',
background_color='transparent',border_color='transparent',
inner_icon_style='font-size:20px')
folium.Marker(
location=[46, -122],
popup='Portland, OR',
icon=icon_star
).add_to(m)
m

But Whein I try to run for a Dataframe on loop of more than 4000 data, the Icon is not plotted, Code below.
icon_star = plugins.BeautifyIcon(icon="star",text_color='#b3334f',
background_color='transparent',border_color='transparent',
inner_icon_style='font-size:20px')
m = folium.Map([28.1, 77.1],zoom_start=8)
for i,rows in df[['Lat','Long']].iterrows():
folium.Marker(location=[rows['Lat'],rows['Long']],icon=icon_star).add_to(m)

This is how my data looks.

I don't know why is this happening, It should give me star plotted for all the lat lon, but I get one single marker which is not a star either.
Environment (please complete the following information):
- Browser => Chrome
- Jupyter Notebook or html files => Jupyter notebook
- Python versions => ys.version_info(major=3, minor=6, micro=10, releaselevel='final', serial=0)
- folium version => 0.11.0
- branca version => 0.4.1
There seems to be a type in your code: icon_star != icon_circle. I don't suppose that was the issue?
No That is not the issue, I was testing another icon to show but that dint work either.
Here is the code which I have used.
icon_star = plugins.BeautifyIcon(icon="star",text_color='#b3334f',
background_color='transparent',border_color='transparent',
inner_icon_style='font-size:20px')
m = folium.Map([28.1, 77.1],zoom_start=8)
for i,rows in df[['Lat','Long']].iterrows():
folium.Marker(location=[rows['Lat'],rows['Long']],icon=icon_star).add_to(m)
m
Hello, I had the same problem. I went around it using:
icon=plugins.BeautifyIcon(icon="star",text_color='#b3334f', background_color='transparent',border_color='transparent', inner_icon_style='font-size:20px')
directly in the loop:
for i,rows in df[['Lat','Long']].iterrows(): folium.Marker(location=[rows['Lat'],rows['Long']],icon=plugins.BeautifyIcon(icon="star",text_color='#b3334f', background_color='transparent',border_color='transparent', inner_icon_style='font-size:20px') ).add_to(m)
I'm trying to use this marker also but it works as a single point not in loop
m = folium.Map(location=[23.4241, 53.8478], tiles="OpenStreetMap", zoom_start=7)
icon_square = folium.plugins.BeautifyIcon(
icon_shape='rectangle-dot',
border_color='red',
border_width=10,
)
folium.Marker([23.4234, 53.8455], tooltip='square', icon=icon_square).add_to(m)
Unfortunately as folium is now you cannot re-use an icon. Instead you have to create each icon object in the loop as well:
m = folium.Map([28.1, 77.1],zoom_start=8)
for i,rows in df[['Lat','Long']].iterrows():
icon_star = plugins.BeautifyIcon(icon="star",text_color='#b3334f',
background_color='transparent',border_color='transparent',
inner_icon_style='font-size:20px')
folium.Marker(location=[rows['Lat'],rows['Long']],icon=icon_star).add_to(m)