Skip to content

Forward unrecognised Leaflet options in path_options - #2272

Merged
hansthen merged 1 commit into
python-visualization:mainfrom
Htet-Kaung-San:fix/vector-layers-passthrough-options
Aug 23, 2026
Merged

Forward unrecognised Leaflet options in path_options#2272
hansthen merged 1 commit into
python-visualization:mainfrom
Htet-Kaung-San:fix/vector-layers-passthrough-options

Conversation

@Htet-Kaung-San

Copy link
Copy Markdown
Contributor

path_options() (shared by Circle, CircleMarker, PolyLine, Polygon, Rectangle) pops the options it names explicitly and builds the result from those, but never forwards the remaining kwargs. So any Leaflet Path option it doesn't list — interactive, pane, renderer, attribution, … — is silently dropped:

from folium.vector_layers import path_options
"interactive" in path_options(radius=10, interactive=False)   # -> False on main

A common case is interactive=False to make a shape non-clickable — on main it just vanishes.

This is inconsistent with the rest of folium: FeatureGroup, LayerGroup, TileLayer, VideoOverlay and GeoJson all forward **kwargs to Leaflet through remove_empty(**kwargs). And path_options already special-cases tags, className and gradient, which shows the intent was to support Leaflet options — the general pass-through was just never added.

The fix forwards the leftover options after the named ones:

    default.update(extra_options)
    default.update(kwargs)   # <- pass remaining Leaflet options through
    return default

The remaining keys are already camelised at the top of the function, so interactive/pane/renderer and snake_case extras (my_optionmyOption) all arrive correctly, and named options are unaffected because they were already popped.

Testing

Two new tests in tests/test_vector_layers.py: one asserting path_options forwards interactive/pane/a custom option, one asserting CircleMarker(..., interactive=False) renders "interactive": false. Both fail on main and pass here.

tests/test_vector_layers.py is 9 passed; the existing 7 are unchanged. ruff check and codespell are clean. Across test_features.py, test_map.py and tests/plugins/, the only failures are test_icon_invalid_marker_colors and test_timedynamic_geo_json, which fail identically on an unmodified checkout.

path_options pops the options it knows about and builds the result from
those, but never forwards the remaining kwargs. Leaflet Path options that
it does not name explicitly -- interactive, pane, renderer, attribution
and so on -- were therefore silently dropped from every vector overlay
(Circle, CircleMarker, PolyLine, Polygon, Rectangle).

This is inconsistent with the rest of folium: FeatureGroup, TileLayer,
GeoJson and the others all forward **kwargs to Leaflet via remove_empty.
The special-cased pass-through of tags, className and gradient shows the
intent was to support Leaflet options, just incompletely.

Forward the leftover options too, so e.g. CircleMarker(..., interactive=
False) actually reaches Leaflet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@hansthen

Copy link
Copy Markdown
Collaborator

Good catch.

@hansthen
hansthen merged commit d2d1e32 into python-visualization:main Aug 23, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants