Interactive Maps¶
to_interactive post-processes the SVG to inject hover tooltips via
embedded JavaScript. The result has no external dependencies and renders
directly in Jupyter or as a standalone HTML file.
from mappyng import Map, BasemapLayer, ChoroplethLayer
m = Map(gdf, width=800, height="auto")
m.add(BasemapLayer())
m.add(ChoroplethLayer(gdf, column="population", method="Quantiles"))
interactive = m.to_interactive(
columns=["LIB_GEO", "population"],
aliases={"LIB_GEO": "Département"},
tooltip={
"background": "rgba(30,30,30,0.92)",
"text_color": "#ffffff",
"font_size": 12,
"border_radius": 6,
"key_weight": "600",
"hover": {
"opacity": 0.8,
"scale": 1.05,
"stroke_width_boost": 1.5,
"shadow": True,
"shadow_color": "rgba(0,0,0,0.4)",
},
},
)
interactive.save("carte.html")
to_interactive parameters¶
Parameter |
Description |
|---|---|
|
List of column names to include in tooltips. All non-internal columns are shown if omitted. |
|
|
|
Appearance dict, fields of |
|
Convenience alias for |
TooltipStyle fields¶
Field |
Default |
Description |
|---|---|---|
|
|
Tooltip background color. |
|
|
Tooltip text color. |
|
11 |
Font size in px. |
|
system sans-serif |
Font family. |
|
4 |
Tooltip corner radius in px. |
|
|
Tooltip border color. |
|
|
Font weight for key labels. |
|
|
Hover effect config: |
HoverEffect fields¶
Field |
Default |
Description |
|---|---|---|
|
|
Master switch. |
|
|
CSS transition timing string. |
|
1.0 |
Element opacity on hover (< 1 = dim). |
|
1.0 |
Scale factor on hover (1.0 = no scaling). |
|
|
Show a CSS drop-shadow on hover. |
|
|
Shadow color. |
|
0.0 / 4.0 |
Shadow offset in SVG px. |
|
8.0 |
Shadow blur radius in SVG px. |
|
1.0 |
Extra stroke-width added on hover (0 = no change). |
|
|
Override stroke color on hover ( |