This notebook shows simple examples of Folium package in order to draw marker on a map.
Colors from flatui colors.
In [1]:
import folium
In [2]:
carte = folium.Map(location=[45.5236, -122.6750], zoom_start=12)
marker = folium.Marker([45.5, -122.7], popup='Un marker')
marker.add_to(carte)
carte
Out[2]:
Help on CircleMarker object :
Init signature: folium.CircleMarker(location, radius=500, color='black', fill_color='black', fill_opacity=0.6, popup=None)
Docstring:
Creates a CircleMarker object for plotting on a Map.
Parameters
----------
location: tuple or list, default None
Latitude and Longitude of Marker (Northing, Easting)
radius: int
The radius of the circle in pixels.
color: str, default 'black'
The color of the marker's edge in a HTML-compatible format.
fill_color: str, default 'black'
The fill color of the marker in a HTML-compatible format.
fill_opacity: float, default à.6
The fill opacity of the marker, between 0. and 1.
popup: string or folium.Popup, default None
Input text or visualization for object.
In [3]:
carte = folium.Map(location=[45.5236, -122.6750], zoom_start=12)
circle = folium.CircleMarker(
[45.5, -122.7],
radius=1000,
popup='Un cercle',
color="#e74c3c", # rouge
fill_color="#27ae60", # vert
fill_opacity=0.9
)
circle.add_to(carte)
carte
Out[3]:
Help on Icon object :
Init signature: folium.Icon(color='blue', icon_color='white', icon='info-sign', angle=0, prefix='glyphicon')
Docstring:
Creates an Icon object that will be rendered
using Leaflet.awesome-markers.
Parameters
----------
color : str, default 'blue'
The color of the marker. You can use:
['red', 'blue', 'green', 'purple', 'orange', 'darkred',
'lightred', 'beige', 'darkblue', 'darkgreen', 'cadetblue',
'darkpurple', 'white', 'pink', 'lightblue', 'lightgreen',
'gray', 'black', 'lightgray']
icon_color : str, default 'white'
The color of the drawing on the marker. You can use colors above,
or an html color code.
icon : str, default 'info-sign'
The name of the marker sign.
See Font-Awesome website to choose yours.
Warning : depending on the icon you choose you may need to adapt
the `prefix` as well.
angle : int, default 0
The icon will be rotated by this amount of degrees.
prefix : str, default 'glyphicon'
The prefix states the source of the icon. 'fa' for font-awesome or
'glyphicon' for bootstrap 3.
Icons can be drawn from bootstrap or font-awesome glyphs. You can chose custum color for the icon but the maker color must be chosen in the provided list (see doc above).
Web sites for glyphs :
In [4]:
carte = folium.Map(location=[45.5236, -122.6750], zoom_start=12)
# add firt marker with bootstrap icon
icone1 = folium.Icon(icon="asterisk", icon_color="#9b59b6", color="lightblue")
marker1 = folium.Marker([45.5, -122.7], popup='Un icone', icon=icone1)
marker1.add_to(carte)
# add second marker with font-awesome icon
icone1 = folium.Icon(icon="globe", icon_color="#e67e22", color="lightgreen", prefix="fa")
marker1 = folium.Marker([45.5, -122.6], popup='Un icone', icon=icone1)
marker1.add_to(carte)
carte
Out[4]:
In [5]:
import matplotlib
import matplotlib.pyplot as plt
In [6]:
color = plt.cm.winter(22)
color
Out[6]:
In [7]:
matplotlib.colors.rgb2hex(color)
Out[7]: