diff --git a/folium/plugins/heat_map_withtime.py b/folium/plugins/heat_map_withtime.py index 88db1ff95a..9f62fb4b31 100644 --- a/folium/plugins/heat_map_withtime.py +++ b/folium/plugins/heat_map_withtime.py @@ -286,15 +286,16 @@ def _get_self_bounds(self): """ bounds = [[None, None], [None, None]] - for point in self.data: - bounds = [ - [ - none_min(bounds[0][0], point[0]), - none_min(bounds[0][1], point[1]), - ], - [ - none_max(bounds[1][0], point[0]), - none_max(bounds[1][1], point[1]), - ], - ] + for points in self.data: + for point in points: + bounds = [ + [ + none_min(bounds[0][0], point[0]), + none_min(bounds[0][1], point[1]), + ], + [ + none_max(bounds[1][0], point[0]), + none_max(bounds[1][1], point[1]), + ], + ] return bounds diff --git a/tests/plugins/test_heat_map_withtime.py b/tests/plugins/test_heat_map_withtime.py index 429a8021d9..320cfc77d7 100644 --- a/tests/plugins/test_heat_map_withtime.py +++ b/tests/plugins/test_heat_map_withtime.py @@ -79,3 +79,17 @@ def test_heat_map_with_time(): """) assert normalize(tmpl.render(this=hm)) in out + + +def test_heat_map_with_time_bounds(): + data = [ + [[50.0, 4.0], [51.0, 5.0]], + [[48.0, 3.0, 0.5], [52.0, 6.0]], + [], + ] + m = folium.Map() + folium.Marker([49.0, 7.0]).add_to(m) + hm = plugins.HeatMapWithTime(data).add_to(m) + + assert hm.get_bounds() == [[48.0, 3.0], [52.0, 6.0]] + assert m.get_bounds() == [[48.0, 3.0], [52.0, 7.0]]