Repository navigation
Keep Search layer hidden when show=False - #2378
Open
vladosskins178 wants to merge 1 commit into
Open
vladosskins178 wants to merge 1 commit into
vladosskins178 wants to merge 1 commit into
Conversation
L.Control.Search adds its layer to the map in onAdd (setLayer calls layer.addTo(map)), so a layer created with show=False became visible as soon as a Search control was attached to it. Remove the layer again right after the control is added when show is False. Fixes python-visualization#2377
This branch has not been 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.
Fixes #2377
L.Control.Searchadds its layer to the map when the control is added:onAddcallssetLayer(this._layer), andsetLayerdoesthis._layer.addTo(this._map)(leaflet-search 2.9.7 source). So a layer created withshow=Falsebecame visible as soon as aSearchcontrol was attached to it, even though folium itself never added it.This removes the layer again right after
addControlwhenlayer.showis False. Layers withshow=Trueare unchanged.Checked in headless Chrome with the issue's setup (a hidden GeoJson with a Search control, plus a shown GeoJson with its own Search control, and a LayerControl):
After switching the hidden layer on in the LayerControl, the search still finds its features.
Tests: two cases in
tests/plugins/test_search.py(hidden layer is removed after the control is added; shown layer is not removed). The first one fails on main.