You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add hexadecimal color code option for marker icon background #1466
There's indeed a PR open on that repo that implements this: lennardv2/Leaflet.awesome-markers#74. I haven't tried it out though, so I don't know how well it works.
Hi @Conengmo! I see this issue has been open for a bit. I am a beginner looking to make some meaningful open-source contributions, and I would love to take a swing at this!
If this is still open and relevant, I'd like to try porting the fix from lennardv2/Leaflet.awesome-markers#74 over to the python-visualization fork as you suggested. Let me know if I'm good to go ahead and start digging in!
Hi @hansthen, thanks for the green light! Quick question: the python-visualization/Leaflet.awesome-markers link mentioned earlier in this thread is currently throwing a 404. Have the awesome-markers assets been vendored directly into the main folium repository since 2022? Just want to make sure I am targeting my PR at the right codebase!
It looks like it. This was before I joined the project. The awesome markers appear to be in map.py (class Icon). But if I look at the code, it also appears to support html color codes.
icon_color : str, default 'white'
The color of the drawing on the marker. You can use colors above,
or an html color code.
@hansthen, thanks for looking into that! You are right that icon_color (the symbol inside supports HTML hex codes.
However, it looks like the color argument (the background of the marker itself) is still restricted to the hardcoded list of strings. If a user passes a hex code there, it currently throws a ValueError.
I'll dive into folium/map.py to look at the Icon class as you suggested, and see if I can implement the hex support for the background color argument. I'll also track down how the awesome-markers CSS is being loaded so I can port the necessary frontend logic!
Hi @hansthen ! Just wanted to loop back and let you know I've opened PR #2211 to fix this.
I ended up bypassing the CDN limitation by dynamically injecting the custom CSS from the Python wrapper whenever a hex color is passed. Let me know what you think when you have a chance to review it!
(Note: Since I'm a first-time contributor here, it looks like the GitHub Actions workflows are currently paused and just need a quick manual approval to run the tests). Thanks!
Activity
Conengmo commentedon Apr 8, 2021
This feature is not implemented in folium, but uses this Leaflet plugin: https://github.com/python-visualization/Leaflet.awesome-markers (link is to a fork hosted on our organization). Found this issue on the original repo that may be interesting: lennardv2/Leaflet.awesome-markers#89
lhoupert commentedon Apr 8, 2021
Thank you it seems that the PR is in the pipeline: lennardv2/Leaflet.awesome-markers#74
lhoupert commentedon Apr 13, 2021
In case it helps someone else, I found a workaround adapting this stackoverflow answer:
which returns:
Conengmo commentedon Nov 18, 2022
There's indeed a PR open on that repo that implements this: lennardv2/Leaflet.awesome-markers#74. I haven't tried it out though, so I don't know how well it works.
Since we are hosting our own fork of that package, we could implement it there: https://github.com/python-visualization/Leaflet.awesome-markers. If somebody wants to open a PR, that's welcome.
dheerusri324 commentedon Feb 24, 2026
Hi @Conengmo! I see this issue has been open for a bit. I am a beginner looking to make some meaningful open-source contributions, and I would love to take a swing at this!
If this is still open and relevant, I'd like to try porting the fix from lennardv2/Leaflet.awesome-markers#74 over to the python-visualization fork as you suggested. Let me know if I'm good to go ahead and start digging in!
hansthen commentedon Feb 24, 2026
Please go ahead. Contributions are greatly appreciated.
dheerusri324 commentedon Feb 25, 2026
Hi @hansthen, thanks for the green light! Quick question: the python-visualization/Leaflet.awesome-markers link mentioned earlier in this thread is currently throwing a 404. Have the awesome-markers assets been vendored directly into the main folium repository since 2022? Just want to make sure I am targeting my PR at the right codebase!
hansthen commentedon Feb 25, 2026
It looks like it. This was before I joined the project. The awesome markers appear to be in map.py (class Icon). But if I look at the code, it also appears to support html color codes.
Maybe this was implemented already.
dheerusri324 commentedon Feb 26, 2026
@hansthen, thanks for looking into that! You are right that icon_color (the symbol inside supports HTML hex codes.
However, it looks like the color argument (the background of the marker itself) is still restricted to the hardcoded list of strings. If a user passes a hex code there, it currently throws a ValueError.
I'll dive into folium/map.py to look at the Icon class as you suggested, and see if I can implement the hex support for the background color argument. I'll also track down how the awesome-markers CSS is being loaded so I can port the necessary frontend logic!
dheerusri324 commentedon Feb 28, 2026
Hi @hansthen ! Just wanted to loop back and let you know I've opened PR #2211 to fix this.
I ended up bypassing the CDN limitation by dynamically injecting the custom CSS from the Python wrapper whenever a hex color is passed. Let me know what you think when you have a chance to review it!
(Note: Since I'm a first-time contributor here, it looks like the GitHub Actions workflows are currently paused and just need a quick manual approval to run the tests). Thanks!
feat: support hexadecimal color codes for Icon marker backgrounds (#1466