Skip to content

Commit 8835ebf

Browse files
authored
Restore bus and line in interactive map layer control (#413)
Fixes a small bug introduced in the last release due to the use of `folium.FeatureGroup`.
1 parent d938430 commit 8835ebf

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

doc/Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ og:description: See what's new in the latest release of Roseau Load Flow !
1919

2020
# Changelog
2121

22+
## Unreleased
23+
24+
- {gh-pr}`413` Restore bus and layers to the layer control in the interactive map plot. This was broken in version
25+
0.13.0.
26+
2227
## Version 0.13.1
2328

2429
- Fix a bug where license validation failed when the English (US) language was not installed on the system (observed on

roseau/load_flow/plotting.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ def _plot_interactive_map_internal(
318318
add_search: bool,
319319
) -> "folium.Map":
320320
import folium
321+
from folium.plugins import FeatureGroupSubGroup, Search
321322

322323
def internal_style_function(feature):
323324
result = style_function(feature) if style_function is not None else None
@@ -410,7 +411,7 @@ def internal_highlight_function(feature):
410411
highlight_function=internal_highlight_function,
411412
tooltip=line_tooltip,
412413
popup=line_popup,
413-
).add_to(network_layer)
414+
).add_to(FeatureGroupSubGroup(network_layer, "Lines").add_to(m))
414415
folium.GeoJson(
415416
data=buses_gdf,
416417
name="buses",
@@ -419,11 +420,9 @@ def internal_highlight_function(feature):
419420
highlight_function=internal_highlight_function,
420421
tooltip=bus_tooltip,
421422
popup=bus_popup,
422-
).add_to(network_layer)
423-
folium.LayerControl().add_to(m)
423+
).add_to(FeatureGroupSubGroup(network_layer, "Buses").add_to(m))
424+
folium.LayerControl(collapsed=False).add_to(m)
424425
if add_search:
425-
from folium.plugins import Search
426-
427426
Search(network_layer, search_label="id", placeholder="Search network elements...").add_to(m)
428427
return m
429428

0 commit comments

Comments
 (0)