Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 854
Kristifer Szabo Avatar asked Mar 24 '16 14:03

Kristifer Szabo


People also ask

Can we change marker appearance in Folium?

There are two things that you can customize to change the appearance of a marker. First, you can change the icon of the marker, and second, you can change the shape of the marker. Folium gives the folium. Icon() class which can be used for creating custom icons for markers.

How do I use font awesome icons in Folium?

If you want to use Fontawesome icons, you put in the icon's name without the prefix (e.g. just "hamburger" without "fa-" in front), then add the prefix keyword argument for Fontawesome, which is fa . See this question as well.

Is Folium available by default?

Folium is a powerful Python library that helps you create several types of Leaflet maps. By default, Folium creates a map in a separate HTML file. Since Folium results are interactive, this library is very useful for dashboard building. You can also create inline Jupyter maps in Folium.


2 Answers

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)
like image 156
G. Deg Avatar answered Sep 29 '22 13:09

G. Deg


In Icon,parameter color is limited, but icon_color can use RBG. Like:

folium.Marker([lat, lon], popup=str(name)+': '+color+'-'+str(clname), icon=folium.Icon(color='black',icon_color='#FFFF00')).add_to(feature_group)
like image 32
Coco Liao Avatar answered Sep 29 '22 13:09

Coco Liao