folium
folium copied to clipboard
Leaflet Control [draft]
Trying out an idea I had based on a number of issues I've encountered. Use the Leaflet Control class to put legends, images or other custom stuff on the map. That way they integrate better with other Leaflet features, such as full screen and potentially layer control.
Before this is ready I'll look at how this combines with layer control. And what the potential benefits are for other folium classes that are currently outside of Leaflet control.
Possibly related issues: https://github.com/python-visualization/folium/issues/450 https://github.com/python-visualization/folium/issues/1344 https://github.com/python-visualization/folium/issues/1079 https://github.com/python-visualization/folium/issues/1167
Some lessons:
- Nearly everything in Leaflet is meant to move with the map. So inheriting from anything related to
L.Layeris not the way to go. - L.Control is static, but can't be switched in LayerControl.
- Adding arbitrary content as a control is one use case, making arbitrary content switchable with layer control is a separate use case.
@Conengmo Would you mind if I continue this branch?
The feature in itself would be really useful. Also, from an architectural perspective, adding a Control base class would also be beneficial, especially for plugins with items that subclass L.Control. These now subclass directly from branca.MacroElement which is not the cleanest solution.