Skip to content
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 SideBySide plugin #1292

Merged
merged 9 commits into from
Nov 10, 2022
Merged

Add SideBySide plugin #1292

merged 9 commits into from
Nov 10, 2022

Conversation

fralc
Copy link
Contributor

@fralc fralc commented Apr 14, 2020

Basic parsing of the leaflet-side-by-side plugin following other plugins implementation

@Conengmo
Copy link
Member

Hi @fralc, thanks for your PR, it looks neat. We already got a PR a while back for the same plugin though: #1032 At that time I didn't merge it because it seemed redundant with the DualMap plugin we already have. Do you think we should reconsider that?

@fralc
Copy link
Contributor Author

fralc commented Apr 16, 2020

Hi @Conengmo, I have not seen DualMap plugin. Actually usages of Leaflet plugins side-by-side and sync mostly coincide. One could expect to find both folium plugins since they are both available at pure Leaflet level and because their user experience is a bit different as sync let you drag a map as the other is synchronized, while side-by-side let you drag a separator between two maps.

However, I do not know which are the principles for introducing folium plugins, so I'm not sure if you should reconsider introducing it.

@Conengmo
Copy link
Member

I defined some criteria for plugin acceptance here: #1080 (comment). I think we're good on all accounts except maybe for the interesting new functionality. But looking back on that previous PR I was maybe a bit too strict. If you would like to add this, then I suppose it's wanted.

To merge this, I think we require:

  • An entry to the plugins example notebook.
  • A different CDN. For github stuff we usually use http://raw.githack.com/.
  • A docstring example that's simpler. Showing all this WMSTileLayer stuff is a bit unnecessary.
  • Importing the class in folium.plugins.

@fralc
Copy link
Contributor Author

fralc commented Apr 24, 2020

@Conengmo I don't see what is wrong with the last commit. It seems a problem with a notebook but I cannot spot the problem. Could you take a look?

@Conengmo
Copy link
Member

Travis build failing is not related to your change. We actually merged a PR yesterday that fixes it, so if you rebase onto master the tests should pass. But you can also leave it like it is now, that's okay.

So is this PR ready for review again?

@fralc
Copy link
Contributor Author

fralc commented Apr 24, 2020

Yes, it is ready for a review

@Conengmo
Copy link
Member

Conengmo commented Apr 25, 2020

Link to notebook changes: https://nbviewer.jupyter.org/github/fralc/folium/blob/master/examples/Plugins.ipynb It seems the notebook outputs are empty.

I have some comments on the controls with this plugin.

Adding the SBS layer to the control doesn't seem to do anything. The slider will appear even if you untoggle it. So we might as well remove the control, overlay and show parameters.

By default if you create a TileLayer object it will have overlay=False. If both the tile layers you pass into SBS have overlay=False only one of them can be activated at the same time. I can think of two ways to resolve this:

  • make it clear in the docstring and plugin notebook that tile layers you want to use in SBS have to have overlay=True.
  • tile layers that are passed into SBS are set to be overlays automatically (e.g. left_layer.overlay = True)

Both is also possible. What are your thoughts on these comments?

Two things about the CDN link: I see I mentioned raw.githack.com before, but that is actually the development subdomain. We should use the rawcdn production subdomain instead. And better to use the minified JS version. https://rawcdn.githack.com/digidem/leaflet-side-by-side/6ea4567fe8d1b3e6ea3b0e9ca05d311f5be125a3/leaflet-side-by-side.min.js should do it.

Other than that no comments. If we can resolve these than I'm sure we're close to merging this.

@Conengmo Conengmo added the waiting for changes This PR has been reviewed and changes are needed before merging label May 21, 2020
@giswqs
Copy link
Contributor

giswqs commented Mar 11, 2022

Any updates on this SideBySide plugin? I would love to use this. See the demo below with ipyleaflet.

Copy link
Member

@Conengmo Conengmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

I updated the class to use our JSCSSMixin, which simplifies dependency statements. Also included a CND link using jsdeliver.net.

Since layer control does nothing for this plugin, I removed those arguments and hard-coded the plugin to not appear in layer control.

Let's merge this when the tests pass.

@Conengmo Conengmo added ready PR is ready for merging and removed waiting for changes This PR has been reviewed and changes are needed before merging labels Nov 10, 2022
@giswqs
Copy link
Contributor

giswqs commented Nov 10, 2022

I think it would be great to have an option that allows users to keep the layers control. This is particularly useful when users want to display multiple layers on the map when the two layers for the layer control do not cover the entire area.

@giswqs
Copy link
Contributor

giswqs commented Nov 10, 2022

Here are some user cases where the layers control would still be useful.
https://leafmap.org/notebooks/49_split_control/

@Conengmo
Copy link
Member

I think that's still possible. Removing the plugin from layer control is only about the sideBySideLayer plugin itself, which is not a layer, and doesn't do anything in layer control

@Conengmo
Copy link
Member

In the first example on the page you shared, I'm talking about the 'Split Control' checkbox which does nothing.

@giswqs
Copy link
Contributor

giswqs commented Nov 10, 2022

Sorry for my misunderstanding. That makes sense. The Split Control itself should not show up as a layer in the layers control It should be removed.

@Conengmo
Copy link
Member

No worries, thanks for looking out!

@Conengmo
Copy link
Member

For anybody checking this out in the future, here's an example of having a base layer and two overlays that can be slided.

m = Map(tiles='cartodbpositron')

layer_right = TileLayer('openstreetmap', overlay=True)
layer_left = TileLayer('stamen toner', overlay=True)

sbs = plugins.SideBySideLayers(layer_left=layer_left, layer_right=layer_right)

layer_left.add_to(m)
layer_right.add_to(m)
sbs.add_to(m)

LayerControl(collapsed=False).add_to(m)

@Conengmo Conengmo merged commit dbd6a96 into python-visualization:main Nov 10, 2022
@giswqs
Copy link
Contributor

giswqs commented Nov 10, 2022

Looking forward to the new release. Thank you!

@Conengmo
Copy link
Member

and thanks to @fralc for the PR! Sorry it took so long.

@fralc
Copy link
Contributor Author

fralc commented Nov 14, 2022

Sorry for not helping with the final steps, thank you for completing this work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PR is ready for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants