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

Added SideBySide plugin basic funcionality #1032

Closed

Conversation

kikocorreoso
Copy link

This PR adds basic functionality provided by this Leaflet plugin similar to the ipyleaflet's SplitMap control.

I've added a notebook in the examples/ directory.

Please, let me know if there is something wrong or if the plugin is not an interesting plugin for folium.

# -*- coding: utf-8 -*-

from __future__ import (absolute_import, division, print_function)
import json

Choose a reason for hiding this comment

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

F401 'json' imported but unused

from jinja2 import Template
from folium.raster_layers import TileLayer, WmsTileLayer

class SideBySide(MacroElement):

Choose a reason for hiding this comment

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

E302 expected 2 blank lines, found 1

Parameters
----------
left_layer : folium TileLayer or WMSTileLayer
A layer to show on the left side of the map. Any layer added to the map

Choose a reason for hiding this comment

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

W291 trailing whitespace

A layer to show on the left side of the map. Any layer added to the map
that is here will be shown on the left.
right_layer : folium TileLayer or WMSTileLayer
A layer to show on the right side of the map. Any layer added to the

Choose a reason for hiding this comment

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

W291 trailing whitespace

that is here will be shown on the left.
right_layer : folium TileLayer or WMSTileLayer
A layer to show on the right side of the map. Any layer added to the
map that is here will be shown on the right. This should not be the

Choose a reason for hiding this comment

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

W291 trailing whitespace

out = m._parent.render()
# Verify that a new side-by-side control is getting created.
assert 'new L.Control.SideBySide' in out

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

with pytest.raises(TypeError):
sbs = SideBySide(tile, marker)
sbs = SideBySide(marker, tile)

Choose a reason for hiding this comment

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

W293 blank line contains whitespace

overlay=False, control=True).add_to(m)
url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi'
wms = WmsTileLayer(url=url, name='test', fmt='image/png',
layers='nexrad-n0r-900913',

Choose a reason for hiding this comment

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

W291 trailing whitespace

url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi'
wms = WmsTileLayer(url=url, name='test', fmt='image/png',
layers='nexrad-n0r-900913',
attr=u'Weather data © 2012 IEM Nexrad',

Choose a reason for hiding this comment

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

W291 trailing whitespace

transparent=True, overlay=True, control=True).add_to(m)
with pytest.raises(ValueError):
sbs = SideBySide(tile, wms, version="whatever")

Choose a reason for hiding this comment

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

W293 blank line contains whitespace
W391 blank line at end of file

@kikocorreoso
Copy link
Author

I've solved the flake8 issues.

@Conengmo
Copy link
Member

Hi, thanks for submitting this PR! I was working on something similar in #933, based on another Leaflet plugin. No reason to have two split map type of plugins, so which Leaflet plugin do you think is better?

@kikocorreoso
Copy link
Author

Hi @Conengmo

Sorry, I didn't see your PR.

Well, maybe there is room for both. I think the functionality is not exactly the same.

@Conengmo
Copy link
Member

Conengmo commented Dec 1, 2018

Can you tell a bit about what's the difference?

@kikocorreoso
Copy link
Author

Well, using the Sync plugin you can show and sync two different maps with different layers so it is useful to provide more information on the same area and to visually compare Several maps.

With the SideBySide plugin you can have the same but on the same map window.

So, with Sync you have to divide the size of the map window in two or more. With the SideBySide you can have a complete view of a map and visually check differences on the same place just moving the control. With Sync plugin you can have something similar using the Sync.Cursor (https://raw.githack.com/jieter/Leaflet.Sync/master/examples/syncCursor_dual.html) but, again, it is not exactly the same and you have a smaller window for both maps. On small screens I would like to have the SideBySide functionality available and, for me, it would be quicker to just move the control to check the differences on the same pixel (or group of pixels) without having to add more code to use the Sync.Cursor functionality.

I think both plugins are useful. SideBySide is for a very specific use while Sync seems more complete.

I don't know if this answer your question.

@ocefpaf ocefpaf force-pushed the master branch 3 times, most recently from 53546b8 to 9f2299a Compare February 26, 2019 19:49
@Conengmo Conengmo mentioned this pull request Apr 16, 2020
@Conengmo
Copy link
Member

This functionality got merged in #1292.

Thank you for your effort @kikocorreoso and apologies this PR didn't work out.

@Conengmo Conengmo closed this Nov 10, 2022
@kikocorreoso
Copy link
Author

Thanks for adding the functionality 🗺️ !!!!!

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

Successfully merging this pull request may close these issues.

3 participants