Foilum map module, trying to get more options for marker colors

Kristifer Szabo picture Kristifer Szabo · Mar 24, 2016 · Viewed 15.9k times · Source

I am playing with Folium a lot right now and its really great to have something so easy to use in Python. But their documentation is seriously behind, which I understand. So I have 2 questions.

  1. What am I doing wrong in how I am trying to get more marker colors? Here is what I have tried:

map.simple_marker(each_coord, popup=v[0], marker_color='#FFFF00') map.simple_marker(each_coord, popup=v[0], marker_color='yellow') map.simple_marker(each_coord, popup=v[0], marker_color='Yellow')

They should all make the marker yellow, instead it stays default red. The only colors I can actually change to are red, green, and purple. In an example from the folium documentation it looks like we should be able to use html color codes:

folium.CircleMarker([45.5215, -122.6261],
                radius=500,
                popup='Laurelhurst Park',
                color='#3186cc',
                fill_color='#3186cc',
               ).add_to(map_2)

But it doesn't work for me. Hope someone knows a way around this because I need at least 12 different colors for my project.

  1. The way I am adding markers seems to be deprecated. It works, but I always get this warning: FutureWarning: simple_marker is deprecated. Use add_children(Marker) instead which I think might be related to why I can't get the colors to work. But their is nothing in any of the documentation or open discussions about how to use add_children Maybe someone with knowledge can clarify?

Thanks

Answer

G. Deg picture G. Deg · Feb 2, 2017

I had the same problem. Here are the colors that work for markers:

colors = [
    'red',
    'blue',
    'gray',
    'darkred',
    'lightred',
    'orange',
    'beige',
    'green',
    'darkgreen',
    'lightgreen',
    'darkblue',
    'lightblue',
    'purple',
    'darkpurple',
    'pink',
    'cadetblue',
    'lightgray',
    'black'
]

folium.Marker([lat, lon], popup=str(name)+': '+color+'-'+str(clname), icon=folium.Icon(color=color)).add_to(feature_group)