-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add layers in Layer #1690
Add layers in Layer #1690
Conversation
I'm OK with this change. It made sense in the past but getting closer to leaflet and snappier maps are worth the breaking changes. We should probably aim to a 1.0 release anyway. So, if you have more breaking changes, now is the time ;-p |
Thank you for the review.
Agreed. I'd like to include the improved documentation, other than that I don't have big ideas for 1.0.
That's a good point. I'll think on it. I did consider doing a refactor of our modules, especially |
@randyzwitch @giswqs since I know you both have projects that use folium, I wanted to give you a heads-up about this upcoming (breaking) change.
Please let me know if you have questions or comments. |
Thanks for the heads up. I will keep an eye on this. |
Our current approach to adding layers to the map and how that works with LayerControl is:
show=False
.This has two issues, one big and one minor:
Address this by letting subclasses of
Layer
only add themselves to their parent ifshow=True
.We can remove the code from each of the subclasses and render it in
Layer
instead.If you're asking, whoever did this in the first place? It was me, my first PR on this project :) #772. Then slight changes were made in LayerControl in #1101.
Downsides
Order of multiple base layers
The downside is that this changes behavior when you add multiple base layers. Currently only the first one is enabled. With this change the last one added will be enabled.
I'm conflicted whether this is something we should want to avoid. It does fit more closely to how Leaflet works. If you want to add multiple TileLayers, you will have to use the
show
parameter to define which one you want to see. For example:Downstream packages
Packages that use folium might suffer from this change, which I would call an internal breaking change. End-users shouldn't notice it, but others that develop using folium may. For example tests that test the correctness of renders will have to update.
folium convention
It may confuse folium developers that Layer subclasses don't add themselves to their parent, while other classes do.
Change parent class of two plugins
SideBySideLayers
currently inherits fromLayer
, but is not actually a layer-type class. Inherit from MacroElement instead.I'll probably split these two changes of into separate PRs.