Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions folium/vector_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
28 changes: 28 additions & 0 deletions tests/test_vector_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading