Beautify Icon does not work when used in a for loop
See original GitHub issueHi
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
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Beautify Icon does not work when used in a for loop
I am using BeautifyIcon to create a star shaped marker. Issue I'm facing is: When I run the below code the , it...
Read more >Beautiful Soup not working in for loop more than once
It is a password-protected website I'm using selenium-wire to get a login and then copy a request body. I can provide the HTML...
Read more >for-Loop in R (10 Examples) | Writing, Running & Using Loops ...
In this Example, I'll illustrate how to use for-loops to loop over a vector. In the following R code, we are specifying within...
Read more >plugins — Folium 0.12.1 documentation - GitHub Pages
Create a BeautifyIcon that can be added to a Marker. Parameters. icon (string, default None) – the Font-Awesome icon name to use to...
Read more >How to Add Drag and Drop in React with React Beautiful DnD
Note: This function can pass in two arguments including a snapshot argument, but we won't be using it in this example. The provided...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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)
Unfortunately as folium is now you cannot re-use an icon. Instead you have to create each icon object in the loop as well: