# How to Make Interactive Maps in Python with Folium

> Make interactive maps in Python with Folium. Add markers and popups, color points by value, cluster them, draw heatmaps and choropleths, and save the map as HTML.

Source: https://www.pythoncharts.com/python/folium-maps-python/ | Published: 2026-11-26 | Author: Alex Scott | Category: Python | Tags: python, folium, map, geospatial, interactive, choropleth, heatmap

To make an interactive map in Python with [Folium](https://python-visualization.github.io/folium/), create `folium.Map(location=[lat, lon], zoom_start=...)`, add layers to it with `.add_to(m)`, and call `m.save("map.html")`. Folium writes [Leaflet](https://leafletjs.com/) maps that you can pan, zoom, and hover.

Install it with `pip install folium pandas`. The examples use Folium 1.0.0, and the choropleth also needs GeoPandas.

## Quick Example

This maps every earthquake of magnitude 6.5 or higher in 2025, using the [USGS earthquake catalog](https://earthquake.usgs.gov/fdsnws/event/1/).

```python
import folium
import pandas as pd

url = ("https://earthquake.usgs.gov/fdsnws/event/1/query?format=csv"
       "&starttime=2025-01-01&endtime=2026-01-01&minmagnitude=5.5&orderby=time")
quakes = pd.read_csv(url)
quakes["lon"] = quakes["longitude"] % 360  # center the map on the Pacific

m = folium.Map(location=[10, 170], zoom_start=2)

for q in quakes[quakes["mag"] >= 6.5].itertuples():
    folium.CircleMarker(
        location=[q.latitude, q.lon],
        radius=(q.mag - 5.5) * 6,
        color="#c1121f",
        weight=1,
        fill=True,
        fill_opacity=0.5,
        tooltip=f"M{q.mag} {q.place}",
    ).add_to(m)

m.save("earthquakes.html")
m  # displays in a notebook
```

<iframe src="https://www.pythoncharts.com/python/folium-maps-python/images/folium-earthquake-map.html" title="Interactive map of 2025 earthquakes of magnitude 6.5 and higher. Hover a circle for its magnitude and place" width="100%" height="420" loading="lazy" style="border: 0"></iframe>

![World map centered on the Pacific with red circles for large 2025 earthquakes, mostly around the Pacific rim, the largest off Kamchatka](https://www.pythoncharts.com/python/folium-maps-python/images/folium-maps-python-quick-example.png)

The query returns 514 earthquakes of magnitude 5.5 or higher, and 45 reach 6.5. The largest was the magnitude 8.8 Kamchatka earthquake in July. USGS revises its catalog, so your counts may differ slightly.

Coordinates are always `[latitude, longitude]`. Taking longitude modulo 360 moves the Americas to the right of Asia, so the Pacific isn't split down the middle.

## Choose a Map Tile Layer

The `tiles` argument sets the background map. The default is OpenStreetMap.

| `tiles=` | Style |
|---|---|
| `"OpenStreetMap"` (default) | Standard street map |
| `"Esri.WorldGrayCanvas"` | Pale grey, good behind colored data |
| `"Esri.WorldImagery"` | Satellite imagery |
| `"OpenTopoMap"` | Terrain with contours |
| `None` | No background |

Many older examples use `"CartoDB Positron"` or `"CartoDB DarkMatter"`. CARTO now requires an API key: Folium 1.0.0 warns about this, and without a key the tiles are stamped "API KEY REQUIRED". Each provider has its own terms and attribution rules, so check them before publishing a map with heavy traffic.

## Add Markers and Popups

`folium.Marker` places a pin. A `tooltip` appears on hover and a `popup` on click. `folium.Popup` accepts HTML, and `folium.Icon` changes the color and symbol.

```python
top = quakes.nlargest(5, "mag")

m = folium.Map(location=[10, 190], zoom_start=2)
for rank, q in enumerate(top.itertuples(), 1):
    folium.Marker(
        location=[q.latitude, q.lon],
        popup=folium.Popup(f"<b>M{q.mag}</b><br>{q.place}<br>{q.time[:10]}",
                           max_width=250),
        tooltip=f"#{rank}: M{q.mag}",
        icon=folium.Icon(color="darkred" if rank == 1 else "blue", icon="info-sign"),
    ).add_to(m)
m
```

![Folium map with pins on the five largest earthquakes of 2025, the largest in dark red off Kamchatka](https://www.pythoncharts.com/python/folium-maps-python/images/folium-markers-popups.png)

If popup text comes from users or an untrusted file, escape it with `html.escape()` first.

## Color Points by Value

A `LinearColormap` from `branca`, which is installed with Folium, turns a number into a color and adds a legend. Here color shows earthquake depth around Fiji and Vanuatu:

```python
import branca.colormap as cm

depth_colors = cm.LinearColormap(["#fee440", "#f15bb5", "#3a0ca3"],
                                 vmin=0, vmax=650, caption="Depth (km)")

m = folium.Map(location=[-18, 180], zoom_start=4, tiles="Esri.WorldGrayCanvas")
for q in quakes.itertuples():
    folium.CircleMarker(
        location=[q.latitude, q.lon], radius=5, stroke=False, fill=True,
        fill_color=depth_colors(q.depth), fill_opacity=0.85,
        tooltip=f"M{q.mag}, {q.depth:.0f} km deep",
    ).add_to(m)
depth_colors.add_to(m)
m
```

![Earthquakes near Fiji and Vanuatu colored by depth, with deep purple events clustered west of Fiji and a depth color bar](https://www.pythoncharts.com/python/folium-maps-python/images/folium-color-by-value.png)

`CircleMarker` sizes are in screen pixels and stay the same at every zoom level. `folium.Circle` takes a radius in meters.

## Cluster Many Markers

Hundreds of overlapping pins are hard to read. `MarkerCluster` groups nearby ones into a count that splits apart as you zoom in.

```python
from folium.plugins import MarkerCluster

m = folium.Map(location=[10, 170], zoom_start=2, tiles="Esri.WorldGrayCanvas")
cluster = MarkerCluster().add_to(m)
for q in quakes.itertuples():
    folium.Marker([q.latitude, q.lon], tooltip=f"M{q.mag} {q.place}").add_to(cluster)
m
```

![Clustered earthquake markers shown as colored circles with counts, including a group of 161 near Japan and Kamchatka](https://www.pythoncharts.com/python/folium-maps-python/images/folium-marker-cluster.png)

## Make a Heatmap

`HeatMap` takes a list of `[latitude, longitude]` pairs and shades areas by point density. Add a third value to each pair to weight it.

```python
from folium.plugins import HeatMap

m = folium.Map(location=[10, 170], zoom_start=2, tiles="Esri.WorldGrayCanvas")
HeatMap(quakes[["latitude", "lon"]].to_numpy().tolist(), radius=12, blur=15).add_to(m)
m
```

![Heatmap of 2025 earthquake locations, brightest off Kamchatka and along the western and southern Pacific](https://www.pythoncharts.com/python/folium-maps-python/images/folium-heatmap.png)

The density is calculated in screen space, so the picture changes as you zoom.

## Draw a Choropleth Map

`folium.Choropleth` colors GeoJSON regions by a value. It accepts a GeoDataFrame, and `key_on` names the property that matches the first column in `columns`. This example shows state population change using Census Bureau boundaries and estimates:

```python
import geopandas as gpd

states = gpd.read_file(
    "https://www2.census.gov/geo/tiger/GENZ2024/shp/cb_2024_us_state_20m.zip"
).to_crs("EPSG:4326")
pop = pd.read_csv(
    "https://www2.census.gov/programs-surveys/popest/datasets/"
    "2020-2025/state/totals/NST-EST2025-ALLDATA.csv")
pop = pop[pop["SUMLEV"] == 40].copy()
pop["STATEFP"] = pop["STATE"].astype(str).str.zfill(2)
pop["growth"] = (pop["POPESTIMATE2025"] / pop["ESTIMATESBASE2020"] - 1) * 100
states = states.merge(pop[["STATEFP", "growth"]], on="STATEFP")
states = states[states["STUSPS"] != "PR"]
states["growth"] = states["growth"].round(1)

m = folium.Map(location=[38, -96], zoom_start=4, tiles="Esri.WorldGrayCanvas")
choropleth = folium.Choropleth(
    geo_data=states, data=states, columns=["STATEFP", "growth"],
    key_on="feature.properties.STATEFP", fill_color="PuOr",
    bins=[-4, -2, 0, 2, 4, 8, 12], fill_opacity=0.8, line_weight=0.5,
    legend_name="Population change, 2020 to 2025 (%)", highlight=True,
    name="Population change",
).add_to(m)
folium.GeoJsonTooltip(fields=["NAME", "growth"],
                      aliases=["State", "Change (%)"]).add_to(choropleth.geojson)
m
```

![Folium choropleth of US population change from 2020 to 2025, with Idaho, Utah, Texas, South Carolina and Florida darkest purple and a few states orange for losses](https://www.pythoncharts.com/python/folium-maps-python/images/folium-choropleth.png)

Idaho grew the most (10.4%), followed by Florida (8.9%), and seven states lost population. Folium maps expect latitude and longitude, so convert projected data with `to_crs("EPSG:4326")`. For a static, publication-style version, see [choropleth maps with GeoPandas](https://www.pythoncharts.com/python/choropleth-map-geopandas/).

## Add a Layer Control

Put markers in `FeatureGroup` layers, add one or more `TileLayer` backgrounds, and finish with `LayerControl`. Readers can then switch them on and off.

```python
m = folium.Map(location=[10, 170], zoom_start=2, tiles=None)
folium.TileLayer("Esri.WorldGrayCanvas", name="Light").add_to(m)
folium.TileLayer("OpenStreetMap", name="Streets", show=False).add_to(m)

shallow = folium.FeatureGroup(name="Shallow (70 km or less)").add_to(m)
deep = folium.FeatureGroup(name="Deeper than 70 km").add_to(m)
for q in quakes.itertuples():
    is_shallow = q.depth <= 70
    folium.CircleMarker(
        [q.latitude, q.lon], radius=3, stroke=False, fill=True, fill_opacity=0.8,
        fill_color="#e85d04" if is_shallow else "#0353a4",
    ).add_to(shallow if is_shallow else deep)

folium.LayerControl(collapsed=False).add_to(m)
m
```

![Map with a layer control for light or street tiles and checkboxes for shallow orange and deeper blue earthquakes](https://www.pythoncharts.com/python/folium-maps-python/images/folium-layer-control.png)

Add `LayerControl` last, after the layers it should list.

## Save and Share a Folium Map

`m.save("map.html")` writes a page you can open in a browser or embed with an `<iframe>`, as the first map here does. The page loads Leaflet from a CDN and tiles from the tile provider, so viewers need an internet connection.

## Folium, Plotly, or GeoPandas?

| Use | When |
|---|---|
| Folium | Street-level web maps with markers, popups, and layers |
| [Plotly maps](https://www.pythoncharts.com/plotly/plotly-geo-maps/) | Maps that sit alongside other interactive Plotly charts |
| GeoPandas | Static maps, projections, and spatial analysis |

## Similar Topics

- [Choropleth maps in Python with GeoPandas](https://www.pythoncharts.com/python/choropleth-map-geopandas/)
- [Geospatial maps in Plotly](https://www.pythoncharts.com/plotly/plotly-geo-maps/)
- [Plot millions of points with Datashader](https://www.pythoncharts.com/python/datashader-millions-points/)
