diff --git a/folium/vector_layers.py b/folium/vector_layers.py index 5b618dfd6a..7a822c57fb 100644 --- a/folium/vector_layers.py +++ b/folium/vector_layers.py @@ -123,6 +123,11 @@ def path_options( "bubblingMouseEvents": kwargs.pop("bubblingMouseEvents", True), } default.update(extra_options) + # Pass any remaining options straight through to Leaflet, matching how + # the other folium option builders forward **kwargs. Without this, Path + # options such as ``interactive``, ``pane`` or ``renderer`` were silently + # dropped from vector overlays. + default.update(kwargs) return default diff --git a/tests/test_vector_layers.py b/tests/test_vector_layers.py index 0cb8ba2183..12ad582aa9 100644 --- a/tests/test_vector_layers.py +++ b/tests/test_vector_layers.py @@ -404,3 +404,31 @@ def test_path_options_lower_camel_case(): options = path_options(fill_color="red", fillOpacity=0.3) assert options["fillColor"] == "red" assert options["fillOpacity"] == 0.3 + + +def test_path_options_passes_through_extra_leaflet_options(): + """Leaflet Path options not named explicitly should not be dropped. + + ``interactive``, ``pane``, ``renderer`` and friends used to vanish from + vector overlays even though the other folium option builders forward + arbitrary **kwargs to Leaflet. + """ + options = path_options( + line=False, + radius=10, + interactive=False, + pane="overlayPane", + custom_option="x", + ) + assert options["interactive"] is False + assert options["pane"] == "overlayPane" + # snake_case is camelised like the named options + assert options["customOption"] == "x" + + +def test_circle_marker_forwards_interactive(): + m = Map() + marker = CircleMarker(location=[0, 0], radius=5, interactive=False) + marker.add_to(m) + rendered = normalize(m._parent.render()) + assert '"interactive": false' in rendered