Quickstart¶
Getting Started¶
To create a base map, simply pass your starting coordinates to Folium:
import folium
map_osm = folium.Map(location=[45.5236, -122.6750])
To dispaly it in a Jupyter notebook, simply ask for the object representation:
map_osm
To save it in a file:
map_osm.save('/tmp/map.html')
Folium defaults to OpenStreetMap tiles, but Stamen Terrain, Stamen Toner, Mapbox Bright, and Mapbox Control room tiles are built in:
folium.Map(location=[45.5236, -122.6750],
tiles='Stamen Toner',
zoom_start=13)
Folium also supports Cloudmade and Mapbox custom tilesets- simply pass your key to the API_key keyword:
folium.Map(location=[45.5236, -122.6750],
tiles='Mapbox',
API_key='your.API.key')
Lastly, Folium supports passing any Leaflet.js compatible custom tileset:
folium.Map(location=[45.372, -121.6972],
zoom_start=12,
tiles='http://{s}.tiles.yourtiles.com/{z}/{x}/{y}.png',
attr='My Data Attribution')
Markers¶
Folium supports the plotting of numerous marker types, starting with a simple Leaflet style location marker with popup text:
map_1 = folium.Map(location=[45.372, -121.6972],
zoom_start=12,
tiles='Stamen Terrain')
folium.Marker([45.3288, -121.6625], popup='Mt. Hood Meadows').add_to(map_1)
folium.Marker([45.3311, -121.7113], popup='Timberline Lodge').add_to(map_1)
map_1
TODO: finish doc here.