foliplus.HeatmapControl#

class foliplus.HeatmapControl(*, position: Literal['topleft', 'topright', 'bottomleft', 'bottomright'] = 'topleft', color_scheme: str = 'Reds', method: Literal['jenks', 'quantile', 'equal', 'heads'] = 'jenks', n_classes: int = 6, agg: Literal['count', 'sum', 'avg', 'min', 'max'] = 'count', schemes: list[str] | None = None, style: dict | None = None, locale: str | LocaleConfig | None = None)[source]#

Bases: BaseControl

H3 hexbin heatmap with zoom-adaptive resolution and labeled hexagons.

Note

Only markers with a .feature property (GeoJSON / df.explore) are counted. Annotation or label markers without .feature are skipped to avoid double-counting in hexbin aggregation.

Parameters#

positionstr, default “topleft”

One of "topleft", "topright", "bottomleft", "bottomright".

color_schemestr, default “Reds”

Default color scheme name. Supports chroma.js / ColorBrewer palettes: Blues, Greens, Reds, Oranges, Purples, YlOrRd, Viridis.

methodLiteral[“jenks”, “quantile”, “equal”, “heads”], default “jenks”

Default classification method.

n_classesint, default 6

Number of classification classes, range 2-9.

aggLiteral[“count”, “sum”, “avg”, “min”, “max”], default “count”

Default aggregation method.

schemeslist[str], optional

List of available color scheme names. Can include custom hex values like ["#f00", "#0f0", "#00f"].

styledict, optional

Grid style overrides. Supported keys:

  • field (optional) property name to aggregate on. null / "auto" counts features per hexagon; any other string aggregates that numeric property.

  • border_weight (float, default 1.5) border width

  • border_color (str, default “#333333”) border color

  • fill_opacity (float, default 0.7) fill opacity

  • border_opacity (float, default 0.9) border opacity

  • label_show (bool, default True) show aggregated value at hex center

  • label_size (int, default 11) label font size

  • label_color (str, default “#fff”) label color

  • label_format (str, default “auto”) number format: "auto" (10K/1K suffix), "int", "comma" (thousands separator)

localestr or LocaleConfig, optional

Language code ("en", "zh") or a LocaleConfig instance. Defaults to auto-detection, falling back to English.

Examples#

>>> import folium
>>> from foliplus import HeatmapControl
>>> m = folium.Map()
>>> HeatmapControl().add_to(m)
__init__(*, position: Literal['topleft', 'topright', 'bottomleft', 'bottomright'] = 'topleft', color_scheme: str = 'Reds', method: Literal['jenks', 'quantile', 'equal', 'heads'] = 'jenks', n_classes: int = 6, agg: Literal['count', 'sum', 'avg', 'min', 'max'] = 'count', schemes: list[str] | None = None, style: dict | None = None, locale: str | LocaleConfig | None = None)[source]#

Methods

__init__(*[, position, color_scheme, ...])

add_child(child[, name, index])

Add a child.

add_children(child[, name, index])

Add a child.

add_css_link(name, url)

Add or update css resource link.

add_js_link(name, url)

Add or update JS resource link.

add_to(parent[, name, index])

Add element to a parent.

get_bounds()

Computes the bounds of the object and all it's children in the form [[lat_min, lon_min], [lat_max, lon_max]].

get_name()

Returns a string representation of the object.

get_root()

Returns the root of the elements tree.

render(**kwargs)

Renders the HTML representation of the element.

save(outfile[, close_file])

Saves an Element into a file.

to_dict([depth, ordered])

Returns a dict representation of the object.

to_json([depth])

Returns a JSON representation of the object.

Attributes

default_css

default_js

default_js: List[Tuple[str, str]] = [('h3-js', 'https://cdn.jsdelivr.net/npm/h3-js@4/dist/h3-js.umd.js'), ('simple-statistics', 'https://cdn.jsdelivr.net/npm/simple-statistics@7/dist/simple-statistics.min.js'), ('chroma-js', 'https://cdn.jsdelivr.net/npm/chroma-js@2/chroma.min.js')]#