Repository navigation
Find OverlappingMarkerSpiderfier markers at render time - #2373
Open
KhadeerBasha1232 wants to merge 1 commit into
Open
KhadeerBasha1232 wants to merge 1 commit into
KhadeerBasha1232 wants to merge 1 commit into
Conversation
The plugin collected its markers in add_to(), so nothing was spiderfied when it was added with add_child(), or when markers were added to an already-attached group afterwards. It also passed its parent to the OverlappingMarkerSpiderfier constructor, which breaks when the parent is a FeatureGroup rather than the map. Collect the markers in render() and pass the map that contains the plugin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KhadeerBasha1232
temporarily deployed
to
pypi
November 20, 2026 17:23 — with
GitHub Actions
Inactive
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Find
OverlappingMarkerSpiderfiermarkers at render timeThe problem
OverlappingMarkerSpiderfiersilently does nothing in three common setups.Added to a
FeatureGroup, to spiderfy only that group's markers:The group is passed to
new OverlappingMarkerSpiderfier(...)as if it were the map. Clicking the stack throwsTypeError: this.map.latLngToLayerPoint is not a function, and the markers stay on top of each other.Added with
add_child:m.add_child(OverlappingMarkerSpiderfier())registers no markers at all, because they're only collected in an overriddenadd_to().Markers added to a group after the plugin: for example, the group is added to the map, then the plugin, then the markers are added to the group. Those markers are missed, because the list is built once when the plugin is added.
The cause
and in the template:
The fix
render()instead ofadd_to(), using the same_get_all_markerswalk over the parent. This is the same patternLayerControland the pattern plugins use.Mapwithget_obj_in_upper_treeand pass that to the constructor and toclosePopup(). Which markers are handled still depends on where the plugin is added, so adding it to a group still limits it to that group.The docstring now says this. It also says the plugin should be added after the markers it handles, since its script refers to them by name.
Before / after
The example above, opened in Chrome, after clicking the stack of six markers.
Tests
Three new tests in
tests/plugins/test_overlapping_marker_spiderfier.py, one per case above. All three fail onmain. The FeatureGroup test also checks that markers outside the group aren't added.