-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 minimap plugin #968
Add minimap plugin #968
Conversation
folium/plugins/minimap.py
Outdated
figure.header.add_child(JavascriptLink('https://cdnjs.cloudflare.com/ajax/libs/leaflet-minimap/3.6.1/Control.MiniMap.js')) # noqa | ||
|
||
figure.header.add_child(CssLink('https://cdnjs.cloudflare.com/ajax/libs/leaflet-minimap/3.6.1/Control.MiniMap.css')) # noqa | ||
figure.add_child(self.tile_layer) |
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.
W292 no newline at end of file
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.
Great PR Colin! This fits folium very well and I'm excited to start using this myself. I have a few comments, hope you can look at them. Also look at the stickler comment about the missing newline.
Should be easy to fix. Then we're good to get merging, after adding a line to the changelog which we'll do at the very last.
folium/plugins/__init__.py
Outdated
@@ -50,4 +51,5 @@ | |||
'TimestampedGeoJson', | |||
'TimestampedWmsTileLayers', | |||
'Search', | |||
'MiniMap' |
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.
Please add a comma
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
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
folium/plugins/minimap.py
Outdated
toggle_display: bool, default | ||
Sets whether the minimap should have a button to minimise it. | ||
|
||
auto_toggle_display: bool, default |
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.
You're missing some default values here
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
folium/plugins/minimap.py
Outdated
collapsed_height: int, default 25 | ||
The height of the toggle marker and the minimap when collapsed | ||
|
||
zoom_level_offset: int, defalut -5 |
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.
typo
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
folium/plugins/minimap.py
Outdated
Parameters | ||
---------- | ||
tile_layer: folium tilelayer, str (Optional) | ||
|
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.
No need to have empty lines between the parameters
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
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.
I'm still seeing them on the 'files changed' page, am I missing something?
folium/plugins/minimap.py
Outdated
|
||
Parameters | ||
---------- | ||
tile_layer: folium tilelayer, str (Optional) |
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.
This could use a line with explanation. e.g.:
tile_layer: folium TileLayer object or str, optional
Provide a folium TileLayer object or the wanted tiles as string.
If not provided it will use the default of `TileLayer`.
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
tests/plugins/test_minimap.py
Outdated
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Test FloatImage |
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.
Wrong title.
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
folium/plugins/minimap.py
Outdated
Set it to any valid zoom level, if unset zoomLevelOffset is used instead. | ||
|
||
center_fixed: bool, default False | ||
Applies a fixed position to the minimap regardless of the main map's view / position. P |
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.
Word is broken
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
One more thing, could you also add a single entry to the plugins notebook? The aim is to have an overview of all available plugins. |
Let me know if you see anything else! |
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.
Thanks for the changes! We're almost there. I'm still seeing some empty lines. Also I have a question about a line I think may be redundant.
By the way, the Travis build failure is unrelated to your edits, so after your next commit (or if we restart it) it should pass.
folium/plugins/minimap.py
Outdated
Parameters | ||
---------- | ||
tile_layer: folium tilelayer, str (Optional) | ||
|
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.
I'm still seeing them on the 'files changed' page, am I missing something?
folium/plugins/minimap.py
Outdated
|
||
def __init__(self, tile_layer=None, position='bottomright', width=150, | ||
height=150, collapsed_width=25, collapsed_height=25, | ||
|
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.
Empty line in between the function arguments
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
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.
Regarding the optional requirement above, It defaults to to whatever TileLayer defaults to (OSM I think) but I'm not sure I should hard code this in. So I put this in which might have been missing when you looked:
https://github.com/talbertc-usgs/folium/blob/minimap/folium/plugins/minimap.py#L23
folium/plugins/minimap.py
Outdated
figure.header.add_child(JavascriptLink('https://cdnjs.cloudflare.com/ajax/libs/leaflet-minimap/3.6.1/Control.MiniMap.js')) # noqa | ||
|
||
figure.header.add_child(CssLink('https://cdnjs.cloudflare.com/ajax/libs/leaflet-minimap/3.6.1/Control.MiniMap.css')) # noqa | ||
figure.add_child(self.tile_layer) |
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.
Is adding self.tile_layer
to figure
needed? It seems the tile layer is already in your template. Can you try if this line is indeed redundant?
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.
Good catch. I'm still getting comfortable with the template usage. I've removed this line.
@talbertc-usgs I made some small changes to finish this PR and merge it, but I'm not allowed to push to your branch. Can you either allow access for folium maintainers to your branch, merge my branch into yours, or copy over the changes? After that I'll merge this. |
folium/folium.py
Outdated
@@ -8,6 +8,7 @@ | |||
from __future__ import (absolute_import, division, print_function) | |||
|
|||
import os | |||
import tempfile |
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 'tempfile' 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.
I merged in your changes but I'm not sure where this stickler issue came from.
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.
It seems git got a bit screwed up. I'm no git wizard so I can't tell exactly what went wrong. I did a rebase and it seems my branch is now okay. Can you try to merge again, or otherwise rebase as well?
Looking good! Nice you got the git thing solved. I'll wait for the travis check to finish and merge this tomorrow. |
Thanks, I'm no git expert either. I can tread water to a certain point,
but then I flail around quite a bit.
…-- Colin
Colin Talbert
Data Manager, Analyst and Developer
US Geological Survey, Fort Collins Science Center
2150 Centre Ave. Bldg. C
Fort Collins, CO 80526
(970) 226-9425
http://orcid.org/0000-0002-9505-1876
Work schedule:
Monday, Thursday - 7:00 - 5:00
Tuesday - Wednesday - 7:00 - 3:10
Friday (Telework) - 7:00 - 5:00
On Mon, Oct 15, 2018 at 3:17 PM Frank ***@***.***> wrote:
Looking good! Nice you got the git thing solved. I'll wait for the travis
check to finish and merge this tomorrow.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#968 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AWHgav86Ig0-QsAbb7cyt-uBha7c0qaQks5ulPtMgaJpZM4W0fCU>
.
|
Merged! Congrats and thanks for your efforts @talbertc-usgs. We'll be looking at your other PR after this. |
Thanks, and thanks for your work on this project.
The second one's not quite as straightforward so let me know.
…-- Colin
Colin Talbert
Data Manager, Analyst and Developer
US Geological Survey, Fort Collins Science Center
2150 Centre Ave. Bldg. C
Fort Collins, CO 80526
(970) 226-9425
http://orcid.org/0000-0002-9505-1876
Work schedule:
Monday, Thursday - 7:00 - 5:00
Tuesday - Wednesday - 7:00 - 3:10
Friday (Telework) - 7:00 - 5:00
On Tue, Oct 16, 2018 at 2:43 AM Frank ***@***.***> wrote:
Merged! Congrats and thanks for your efforts @talbertc-usgs
<https://github.com/talbertc-usgs>. We'll be looking at your other PR
after this.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#968 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AWHgahYo1VsK9KUrSxXx1CT9guUPxWEfks5ulZwbgaJpZM4W0fCU>
.
|
Thanks @talbertc-usgs! Awesome PR!! And thanks for @Conengmo for the nice review. This is a nice addition to |
I wanted a locator map and luckily found this plugin:https://github.com/Norkart/Leaflet-MiniMap
The realm of what is possible in leaflet is awesome!
Hopefully this pluggin can be useful to others. See it in action here: http://nbviewer.jupyter.org/github/talbertc-usgs/folium/blob/minimap/examples/MiniMap.ipynb