folium icon indicating copy to clipboard operation
folium copied to clipboard

Add PolyLine Offset plugin

Open FabeG opened this issue 7 years ago • 6 comments

It would be nice to implement the PolyLine Offset plugin (can be found here : https://github.com/bbecquet/Leaflet.PolylineOffset), in order to draw parallel polylines. I can propose a PR if you think it might be interesting.

FabeG avatar Mar 05 '19 09:03 FabeG

@FabeG while I'm not against adding this to the folium plugin submodule you can create the plugin as a separete package. That would allow you to evolve the plugin faster, without waiting for folium releases and review process.

ocefpaf avatar Mar 06 '19 13:03 ocefpaf

Thanks for your answer @ocefpaf. Actually, I had just developped this plugin for my own needs (not too difficult: inheritance from PolyLine class, just adding an offset argument), and I was wondering if it could be also useful for other folium users. No problem then if you think integrating this plugin in the folium plugin submodule is not that interesting.

FabeG avatar Mar 06 '19 14:03 FabeG

No problem then if you think integrating this plugin in the folium plugin submodule is not that interesting.

It is not that it is uninteresting. It is about maintenance burden and quick development. At the early stages of folium we incorporated all the plugins and that makes it hard for us now to update the underlying JS libraries and still get all the code to pass the tests. In hindsight we should've done the same model as leaflet itself, where each plugin is a different package. I do encourage you to make that plugin a separate package, if not, maybe @Conengmo may be a better person to ask if we should add that to folium itself or not.

ocefpaf avatar Mar 06 '19 14:03 ocefpaf

Hmm I agree on making sure we don't overburden ourselves with features. But then I don't think most of our time goes to light-weight plugins. If we only provide a simple wrapper around a Javascript plugin, we don't have that much to maintain, while providing possibly useful functionality. I also see the value of having a single authoritative package for discovery.

But some current plugins do make our lives hard. TimeSliderChoropleth comes to mind. Maybe we can define some criteria on which to decide whether new plugins are wanted. Here's a proposal:

  • the plugin provides interesting new functionality.
  • the wrapper template is simple.
  • the wrapper class has not much logic, just passing some things to the template.
  • no/little integration with other folium classes.

As well as these criteria for the process:

  • the contributor communicates well.
  • the first PR is of reasonably good quality.
  • the contributor can add a docstring, tests, entry in the plugins notebook and possibly a standalone example notebook.

@FabeG I think the plugin you link to is quite simple and won't make folium that much more complex. I'm thinking it could be a class that just calls (in JS) pl.setOffset() on a PolyLine. That seems simpler than inheriting and providing the same arguments twice. So if you want to add this contribution to folium (including tests and example notebook) I'd be happy to review.

Conengmo avatar Mar 10 '19 16:03 Conengmo

Hi @Conengmo, I submitted a PR (#1091), including tests and example notebook. I created a PolyLineOffset class in the plugins folder (so not totally in line with your proposal, but at least it would allow us to start a discussion) that inherits from Polyline class, adding only an offset option. A review would be appreciated :)

FabeG avatar Mar 12 '19 10:03 FabeG

This feature was merged in https://github.com/python-visualization/folium/pull/1091

Conengmo avatar Nov 25 '22 11:11 Conengmo