Skip to content


folium makes it easy to visualize data that’s been manipulated in Python on an interactive leaflet map. It enables both the binding of data to a map for choropleth visualizations as well as passing rich vector/raster/HTML visualizations as markers on the map.

The library has a number of built-in tilesets from OpenStreetMap, Mapbox, and Stamen, and supports custom tilesets with Mapbox or Cloudmade API keys. folium supports both Image, Video, GeoJSON and TopoJSON overlays.

Use dash-leaflet if you want to do complex stuff.

If you want to do multiple filters on the plotted data or connect the map with other graphics, use dash-leaflet instead.


Although you can install it with pip install folium their release pace is slow, therefore I recommend pulling it directly from master

pip install git+

It's a heavy repo, so it might take some time.


Use the following snippet to create an empty map centered in Spain

import folium

m = folium.Map(
    location=[40.0884, -3.68042],

# Map configuration goes here"map.html")

From now on, those lines are going to be assumed, and all the snippets are supposed to go in between the definition and the save.

If you need to center the map elsewhere, I suggest that you configure the map to show the coordinates of the mouse with

from folium.plugins import MousePosition


Change tileset

Folium Map object supports different tiles by default. It also supports any WMS or WMTS by passing a Leaflet-style URL to the tiles parameter: http://{s}{z}/{x}/{y}.png.

To use the IGN beautiful map as a fallback and the OpenStreetMaps as default use the following snippet:

m = folium.Map(
    location=[40.0884, -3.68042],



We need to set the tiles=None in the Map definition so both are shown in the LayerControl menu.

Loading the data

Using geojson

folium.GeoJson("my_map.geojson", name="geojson").add_to(m)

If you don't want the data to be embedded in the html use embed=False, this can be handy if you don't want to redeploy the web application on each change of data. You'll need to supply a valid url to the data file.

The downside (as of today) of using geojson is that you can't have different markers for the data. The solution is to load it and iterate over the elements. See the issue for more information.

Using gpx

Another popular data format is gpx, which is the one that OsmAnd uses. To import it we'll use the gpxpy library.

import gpxpy
import gpxpy.gpx

gpx_file = open('map.gpx', 'r')
gpx = gpxpy.parse(gpx_file)


Use examples

Search examples

It seems that it doesn't yet support searching for multiple attributes in the geojson data

Last update: 2020-11-11