From 75ce7e332b81aa0821e5d1b376a4724066403fc4 Mon Sep 17 00:00:00 2001 From: KhadeerBasha1232 Date: Mon, 16 Nov 2026 17:53:48 +0530 Subject: [PATCH] Add pane option to HeatMapWithTime The heatmap library always appended its element to the overlay pane with no z-index, so any ImageOverlay (Leaflet gives it a z-index) covered the heatmap no matter the order the layers were added. HeatMapWithTime now takes a `pane` argument. Combined with a CustomPane that has a higher z_index, the heatmap can be drawn on top of image overlays. The default stays "overlayPane", so existing maps render as before. Closes #1400 Co-Authored-By: Claude Opus 5.5 --- docs/user_guide/plugins/heatmap_with_time.md | 16 ++++++++++++ folium/plugins/heat_map_withtime.py | 26 ++++++++++++++++++-- tests/plugins/test_heat_map_withtime.py | 18 +++++++++++++- 3 files changed, 57 insertions(+), 3 deletions(-) diff --git a/docs/user_guide/plugins/heatmap_with_time.md b/docs/user_guide/plugins/heatmap_with_time.md index 956759a513..6536e41f38 100644 --- a/docs/user_guide/plugins/heatmap_with_time.md +++ b/docs/user_guide/plugins/heatmap_with_time.md @@ -74,3 +74,19 @@ hm.add_to(m) m ``` + +### Drawing on top of image overlays + +Image overlays cover the heatmap by default, even when the heatmap is added later. To draw the heatmap on top, put it in a custom pane with a higher `z_index`. + +```{code-cell} ipython3 +m = folium.Map([48.0, 5.0], zoom_start=6) + +folium.map.CustomPane("heatmap", z_index=450).add_to(m) + +hm = folium.plugins.HeatMapWithTime(data, pane="heatmap") + +hm.add_to(m) + +m +``` diff --git a/folium/plugins/heat_map_withtime.py b/folium/plugins/heat_map_withtime.py index 9f62fb4b31..bf0ee43be1 100644 --- a/folium/plugins/heat_map_withtime.py +++ b/folium/plugins/heat_map_withtime.py @@ -54,12 +54,31 @@ class HeatMapWithTime(JSCSSMixin, Layer): Whether the Layer will be included in LayerControls. show: bool, default True Whether the layer will be shown on opening. + pane: str, default "overlayPane" + Name of the map pane the heatmap is drawn in. Use a + :class:`folium.map.CustomPane` with a higher ``z_index`` to draw the + heatmap on top of image overlays, which otherwise cover it. """ _template = Template(""" {% macro header(this, kwargs) %}