-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Add FeatureGroupSubGroup plugin #875
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 FeatureGroupSubGroup plugin #875
Conversation
|
||
def __init__(self, group, name=None, overlay=True, control=True, show=True): | ||
super(FeatureGroupSubGroup, self).__init__(name=name, overlay=overlay, | ||
control=control, show=show) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E128 continuation line under-indented for visual indent
@ghybs FYI. |
409f72a
to
b1880ce
Compare
This plugin [0] allows can be used to either: * create nested overlays that can be turned on or off together or separately, ```python fg = folium.FeatureGroup() m.add_child(fg) g1 = folium.plugins.FeatureGroupSubGroup(fg, 'g1') m.add_child(g1) g2 = folium.plugins.FeatureGroupSubGroup(fg, 'g2') m.add_child(g2) folium.LayerControl().add_to(m) ``` * make multiple overlays part of the same MarkerCluster, ```python mcg = folium.plugins.MarkerCluster(control=False) m.add_child(mcg) g1 = folium.plugins.FeatureGroupSubGroup(mcg, 'g1') m.add_child(g1) g2 = folium.plugins.FeatureGroupSubGroup(mcg, 'g2') m.add_child(g2) folium.LayerControl().add_to(m) ``` [0] https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup Signed-off-by: Olivier Mehani <[email protected]>
b1880ce
to
d5c3342
Compare
This looks great, well done. This fits in well I think. Before I merge I have two requests:
Also, if you have the time, I would welcome a test. You could for example look at tests/plugins/test_marker_cluster.py for a way to do this. |
Signed-off-by: Olivier Mehani <[email protected]>
|
||
import folium | ||
|
||
from folium import plugins |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'folium.plugins' imported but unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
|
||
from jinja2 import Template | ||
|
||
import numpy as np |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F401 'numpy as np' imported but unused
m.add_child(fg) | ||
g1 = folium.plugins.FeatureGroupSubGroup(fg, 'g1') | ||
m.add_child(g1) | ||
folium.Marker([1,1]).add_to(g1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E231 missing whitespace after ','
g1 = folium.plugins.FeatureGroupSubGroup(fg, 'g1') | ||
m.add_child(g1) | ||
folium.Marker([1,1]).add_to(g1) | ||
folium.Marker([-1,-1]).add_to(g1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E231 missing whitespace after ','
folium.Marker([1,1]).add_to(g1) | ||
folium.Marker([-1,-1]).add_to(g1) | ||
g2 = folium.plugins.FeatureGroupSubGroup(fg, 'g2') | ||
folium.Marker([-1,1]).add_to(g2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E231 missing whitespace after ','
folium.Marker([-1,-1]).add_to(g1) | ||
g2 = folium.plugins.FeatureGroupSubGroup(fg, 'g2') | ||
folium.Marker([-1,1]).add_to(g2) | ||
folium.Marker([1,-1]).add_to(g2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E231 missing whitespace after ','
folium.Marker([-1,1]).add_to(g2) | ||
folium.Marker([1,-1]).add_to(g2) | ||
m.add_child(g2) | ||
l = folium.LayerControl().add_to(m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
F841 local variable 'l' is assigned to but never used
I added a test, quickly hacked from what I could gather from the MarkerCluster one, but couldn't work out how to exercise it. Neither running |
ca5983b
to
16bb591
Compare
m.add_child(fg) | ||
g1 = folium.plugins.FeatureGroupSubGroup(fg, 'g1') | ||
m.add_child(g1) | ||
folium.Marker( [1,1] ).add_to(g1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E201 whitespace after '('
E231 missing whitespace after ','
E202 whitespace before ')'
g1 = folium.plugins.FeatureGroupSubGroup(fg, 'g1') | ||
m.add_child(g1) | ||
folium.Marker( [1,1] ).add_to(g1) | ||
folium.Marker( [-1,-1] ).add_to(g1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E201 whitespace after '('
E231 missing whitespace after ','
E202 whitespace before ')'
folium.Marker( [1,1] ).add_to(g1) | ||
folium.Marker( [-1,-1] ).add_to(g1) | ||
g2 = folium.plugins.FeatureGroupSubGroup(fg, 'g2') | ||
folium.Marker( [-1,1] ).add_to(g2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E201 whitespace after '('
E231 missing whitespace after ','
E202 whitespace before ')'
folium.Marker( [-1,-1] ).add_to(g1) | ||
g2 = folium.plugins.FeatureGroupSubGroup(fg, 'g2') | ||
folium.Marker( [-1,1] ).add_to(g2) | ||
folium.Marker( [1,-1] ).add_to(g2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E201 whitespace after '('
E231 missing whitespace after ','
E202 whitespace before ')'
16bb591
to
926c41d
Compare
m.add_child(fg) | ||
g1 = plugins.FeatureGroupSubGroup(fg, 'g1') | ||
m.add_child(g1) | ||
folium.Marker( [1,1] ).add_to(g1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E201 whitespace after '('
E231 missing whitespace after ','
E202 whitespace before ')'
g1 = plugins.FeatureGroupSubGroup(fg, 'g1') | ||
m.add_child(g1) | ||
folium.Marker( [1,1] ).add_to(g1) | ||
folium.Marker( [-1,-1] ).add_to(g1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E201 whitespace after '('
E231 missing whitespace after ','
E202 whitespace before ')'
folium.Marker( [1,1] ).add_to(g1) | ||
folium.Marker( [-1,-1] ).add_to(g1) | ||
g2 = plugins.FeatureGroupSubGroup(fg, 'g2') | ||
folium.Marker( [-1,1] ).add_to(g2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E201 whitespace after '('
E231 missing whitespace after ','
E202 whitespace before ')'
folium.Marker( [-1,-1] ).add_to(g1) | ||
g2 = plugins.FeatureGroupSubGroup(fg, 'g2') | ||
folium.Marker( [-1,1] ).add_to(g2) | ||
folium.Marker( [1,-1] ).add_to(g2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E201 whitespace after '('
E231 missing whitespace after ','
E202 whitespace before ')'
Signed-off-by: Olivier Mehani <[email protected]>
926c41d
to
d9b6fe1
Compare
The code that adds markers was copied from test_marker_cluster.py. It does nothing here since the FeatureGroupSubGroup object has no children.
Merged. Thanks @shtrom! Your test was fine and thanks also for adding the examples to the notebook. |
This plugin [0] allows can be used to either:
[0] https://github.com/ghybs/Leaflet.FeatureGroup.SubGroup
Signed-off-by: Olivier Mehani [email protected]