Skip to content

geohierarchy.maps.folium.maplibre_render

MapLibre GL JS rendering for PMTiles and H3J/H3T formats.

generate_maplibre_html(output_path, sources, layers, basemap='osm', center=None, zoom=12, title='Map', include_h3j_h3t=False, include_pmtiles=False, legend_html=None, extra_css=None, extra_js=None)

Write a standalone MapLibre GL JS page from ready-made sources and layers.

Parameters:

Name Type Description Default
output_path Union[str, Path]

HTML file to write (parent folders are created).

required
sources Dict[str, Dict[str, Any]]

MapLibre sources {id: source spec}; a raster basemap source is added.

required
layers List[Dict[str, Any]]

MapLibre layer specs, drawn above the basemap in order.

required
basemap str

Basemap name (see the basemap table of this module) or a custom spec.

'osm'
center Optional[Sequence[float]]

(lon, lat) of the initial view; None lets the page fit the data.

None
zoom int

Initial zoom.

12
title str

Page title.

'Map'
include_h3j_h3t bool

Load the H3 JSON / H3 tile protocol scripts.

False
include_pmtiles bool

Load the PMTiles protocol script.

False
legend_html Optional[str]

Optional HTML placed as the legend.

None
extra_css Optional[str]

Optional CSS added to the page.

None
extra_js Optional[str]

Optional JavaScript run after the map loads.

None

Returns:

Type Description
Path

Path of the written HTML file.

generate_mixed_html(pmtiles_paths=None, h3j_paths=None, h3t_dirs=None, output_path='map.html', layer_styles=None, zoom_ranges=None, basemap='osm', center=None, zoom=12, title='Map', **kwargs)

Write a MapLibre page mixing PMTiles archives, H3 JSON files and H3 tile folders, one layer each.

Parameters:

Name Type Description Default
pmtiles_paths Optional[Dict[str, Path]]

{layer name: .pmtiles file}.

None
h3j_paths Optional[Dict[str, Path]]

{layer name: H3 JSON file}.

None
h3t_dirs Optional[Dict[str, Path]]

{layer name: H3 tile folder}.

None
output_path Union[str, Path]

HTML file to write.

'map.html'
layer_styles Optional[Dict[str, Dict[str, Any]]]

Optional {layer name: paint / layout overrides}.

None
zoom_ranges Optional[Dict[str, tuple]]

Optional {layer name: (min zoom, max zoom)}.

None
basemap str

Basemap name or spec.

'osm'
center Optional[Sequence[float]]

(lon, lat) of the initial view.

None
zoom int

Initial zoom.

12
title str

Page title.

'Map'
kwargs Any

Passed on to :func:generate_maplibre_html.

{}

Returns:

Type Description
Path

Path of the written HTML file.