Skip to content

geohierarchy.maps.basemap

MapLibre vector-tile background maps for Folium maps.

Folium/Leaflet only draws raster tiles on its own. This module adds a MapLibre GL vector-tile style (served by OpenFreeMap, no API key) as the background of a Folium map, through the maplibre-gl-leaflet bridge:

m = folium.Map(location=[42.37, -71.12], zoom_start=13, tiles=None)
add_basemap(m, "positron")

Styles: https://openfreemap.org

add_basemap(m, style=DEFAULT_BASEMAP)

Use a MapLibre vector-tile style as the background of a Folium map.

Create the map with tiles=None so no raster background is added.

Parameters:

Name Type Description Default
m Map

The Folium map.

required
style str

A key of :data:BASEMAP_STYLES ("positron", "bright", "liberty", "dark") or the URL of any MapLibre style JSON.

DEFAULT_BASEMAP

Returns:

Type Description
Map

m, for chaining.