-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Allow popups to be open on page load #778
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
Conversation
Everything looks good to go! Thanks!! Can you:
Regarding your questions:
I guess we can keep it simple and just name it
I like it. Simple and "hackable." I don't really want to wrap everything leaflet can do with popups b/c I am not sure the complexity is worth it. However, this extra keyword makes sense to me.
This is what I am on the fence. I don't really want to make it overly complex. open by default is very useful, the other not so much. I can be convinced otherwise but I don't think it is worth investing in that.
I may be wrong but |
@ocefpaf thanks for the feedback!
I think what you're getting after is that if someone changes the template, maybe my
Sounds good to me, and I think
Once we confirm on the few remaining items above, I'll re-push a [hopefully] final commit! |
Yes it does. Sorry. We should not shadow builtin and I an terrible with names. Maybe we should name it
Yep. Unfortunately that is not much we can do beyond that. Still that kind of test help a lot when adding other features and ensuring that we don't break this one. I'll get to the rest of your PR and message later. I have to go back to the day job now 😬 |
Taking a break from my day job :)
I thought about
Sounds good. I'm a little swamped now that the weekend is over and I have to actually do work again. I'm probably good on input until I figure out how to write a test (and I'll just look at some of the other tests for ideas). Thanks! |
No problem. I won't have time to review it until the end of the year 😬 |
…n#791) * Set min_zoom default to Leaflet value (0) * Change min_zoom in test
Update. Per discussion on #784 , I rather like the new idea that's come up to split the open on load and clicking behavior into separate options. I also like the names. The proposal:
I just made these changes and things seem to work nicely. Here's a jupyter notebook I used to run through the combos (to try you'll obviously need to install my branch). |
* Added max_native_zoom keyword
List both 0.5.0 and master docs
Set overlays untoggled in LayerControl
Fix: max_native_zoom in test
Hi @jwhendy, I want to continue on working to merge this PR. I think it's great, really simple and effective. Do you want to help with two final things?
|
Pretty sure I'm rebased correctly on top of I'm still feeling quite dense on this test thing... from your example code, what would
|
Good that you solved the conflicts. I'm assuming you will push that commit later. Weird that you're getting an empty string. Maybe you can try using another test as an example, e.g.
Note that we can accept this pull request without a test, so if it's too much trouble we can leave it out. But of course it would be good to figure this out. |
folium/map.py
Outdated
{% endfor %} | ||
""") # noqa | ||
|
||
|
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.
W293 blank line contains whitespace
folium/map.py
Outdated
""") # noqa | ||
|
||
|
||
def __init__(self, html=None, parse_html=False, max_width=300, show=False, sticky=False): |
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.
E303 too many blank lines (2)
tests/test_map.py
Outdated
, autoClose: false | ||
, closeOnClick: false}}); | ||
|
||
|
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.
W293 blank line contains whitespace
tests/test_map.py
Outdated
|
||
var {1} = $(\'<div id="{1}" style="width: 100.0%; height: 100.0%;">Some text.</div>\')[0]; | ||
{0}.setContent({1}); | ||
|
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.
W293 blank line contains whitespace
tests/test_map.py
Outdated
|
||
{2}.bindPopup({0}); | ||
|
||
|
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.
W293 blank line contains whitespace
tests/test_map.py
Outdated
|
||
assert rendered == expected | ||
|
||
|
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.
W293 blank line contains whitespace
tests/test_map.py
Outdated
, autoClose: false | ||
}}); | ||
|
||
|
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.
W293 blank line contains whitespace
tests/test_map.py
Outdated
|
||
var {1} = $(\'<div id="{1}" style="width: 100.0%; height: 100.0%;">Some text.</div>\')[0]; | ||
{0}.setContent({1}); | ||
|
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.
W293 blank line contains whitespace
tests/test_map.py
Outdated
|
||
{2}.bindPopup({0}); | ||
|
||
|
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.
W293 blank line contains whitespace
tests/test_map.py
Outdated
|
||
|
||
""".format(popup.get_name(), | ||
list(popup.html._children.items())[0][0], |
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
tests/test_map.py
Outdated
|
||
var {1} = $(\'<div id="{1}" style="width: 100.0%; height: 100.0%;">Some text.</div>\')[0]; | ||
{0}.setContent({1}); | ||
|
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.
W293 blank line contains whitespace
tests/test_map.py
Outdated
|
||
{2}.bindPopup({0}); | ||
|
||
|
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.
W293 blank line contains whitespace
tests/test_map.py
Outdated
|
||
|
||
""".format(popup.get_name(), | ||
list(popup.html._children.items())[0][0], |
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
I think I'm good, or pretty darn close at this point. Sorry that the git commit history is pretty gross...
Edit: Oh, and I'm near positive I had an issue with the locally installed branch not printing with |
Great, seems like we're almost there. Don't worry about the commit history, we'll squash it. First of all, it seems that the
What are doing seems fine. You can also directly get the keys instead of the items:
It's a new feature, not an API change that users will have to deal with. So you can add it in the main list.
Yeah that one's a bit annoying isn't it. We'll have to fix these lint errors though, otherwise the code will become a mess. What you have to do is make sure that there aren't any spaces on your blank lines. You don't have to add another blank line, just remove the spaces from it. For example in map.py there are now two blank lines before the init of Popup, remove one and make sure there are no spaces on the remaining line. Finally, I have a suggestion for your tests. Right now the spaces and newlines have to be exactly the same in comparing rendered and expected. You can make it more robust by removing whitespaces and newlines before comparing. You could copy over the |
@Conengmo All sounds great. I'll have this done tonight. Appreciate the tips on the test (such a great idea and newlines/spaces killed me trying to get right!) and where to add the changelog bit. I'm not surprised there were accidental spaces an will fix those. For this:
I actually thought |
I think we're good now!
Aaannnnd, while I was re-reading your comments for maybe the fourth time... how the heck did I miss this staring me in the face:
Indeed it did! I blame rebasing on |
Woo-hoo! And thanks to you for your patience/coaching! I learned quite a few things. |
Good to hear. And remember you're always welcome to pick up another issue, or contribute by commenting/reviewing other stuff. |
Hey guys, any idea why I can't seem to use the new properties yet? Is it because it hasn't been released yet?
|
Indeed it hasn't been released yet to Pypi. So if you're on version 0.5 it won't work. Try installing it from GitHub. |
This is a first stab at #210 , but should probably have some input from the community.
Currently, this creates a new argument,
folium.Popup(..., default_open=False)
which utilizesautoClose
option fromL.popup
. This was found on this SO question in which a couple answers citedautoClose: false
.This issue is also enlightening, as there are some other nuanced arguments that control the behavior we might want to consider in
folium
. For example, theautoClose
docs say:However, the popup will still close when you click another popup because you're also considered to be clicking on the map itself. Currently this PR assumes that if you want them to be open on load, you don't want them to close when clicking another, so
closeOnClick
is also applied ifdefault_open=True
is used.Lastly, there's an argument to
L.map()
that could also be relevant,closePopupOnClick
.Some items I think should be reviewed:
default_open
{% if this.default_open %}, autoClose: false, closeOnClick: false{% endif %}});
)?autoClose
,closeOnClick
, andclosePopupOnClick
?folium.Popup
the right place to add this, or does it make sense any higher up in the chain likefolium.Marker
orfolium.Map
(leaning toward it being correct as it is, which mapsleaflet
options directly to theirfolium
analogs).Anything else? I'm newer to
python
and know nearly zilch ofjavascript
, so comments/feedback are welcome!