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 minimap plugin #968

Merged
merged 14 commits into from
Oct 16, 2018
Merged

Conversation

ColinTalbert
Copy link
Contributor

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

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)

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

@ColinTalbert ColinTalbert mentioned this pull request Sep 21, 2018
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.

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.

@@ -50,4 +51,5 @@
'TimestampedGeoJson',
'TimestampedWmsTileLayers',
'Search',
'MiniMap'
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comma

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

toggle_display: bool, default
Sets whether the minimap should have a button to minimise it.

auto_toggle_display: bool, default
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

collapsed_height: int, default 25
The height of the toggle marker and the minimap when collapsed

zoom_level_offset: int, defalut -5
Copy link
Member

Choose a reason for hiding this comment

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

typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Parameters
----------
tile_layer: folium tilelayer, str (Optional)

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Member

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?


Parameters
----------
tile_layer: folium tilelayer, str (Optional)
Copy link
Member

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`.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

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

"""
Test FloatImage
Copy link
Member

@Conengmo Conengmo Sep 28, 2018

Choose a reason for hiding this comment

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

Wrong title.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

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
Copy link
Member

Choose a reason for hiding this comment

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

Word is broken

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@Conengmo Conengmo changed the title Add inital minimap plugin Add minimap plugin Sep 28, 2018
@Conengmo
Copy link
Member

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.

@ColinTalbert
Copy link
Contributor Author

Let me know if you see anything else!

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.

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.

Parameters
----------
tile_layer: folium tilelayer, str (Optional)

Copy link
Member

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?


def __init__(self, tile_layer=None, position='bottomright', width=150,
height=150, collapsed_width=25, collapsed_height=25,

Copy link
Member

@Conengmo Conengmo Oct 13, 2018

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor Author

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

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)
Copy link
Member

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?

Copy link
Contributor Author

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.

@Conengmo
Copy link
Member

@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.

@Conengmo Conengmo added the waiting for changes This PR has been reviewed and changes are needed before merging label Oct 15, 2018
folium/folium.py Outdated
@@ -8,6 +8,7 @@
from __future__ import (absolute_import, division, print_function)

import os
import tempfile

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

Copy link
Contributor Author

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.

Copy link
Member

@Conengmo Conengmo Oct 15, 2018

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?

@Conengmo
Copy link
Member

Looking good! Nice you got the git thing solved. I'll wait for the travis check to finish and merge this tomorrow.

@Conengmo Conengmo removed the waiting for changes This PR has been reviewed and changes are needed before merging label Oct 15, 2018
@ColinTalbert
Copy link
Contributor Author

ColinTalbert commented Oct 15, 2018 via email

@Conengmo Conengmo merged commit 584ea34 into python-visualization:master Oct 16, 2018
@Conengmo
Copy link
Member

Merged! Congrats and thanks for your efforts @talbertc-usgs. We'll be looking at your other PR after this.

@ColinTalbert
Copy link
Contributor Author

ColinTalbert commented Oct 16, 2018 via email

@ocefpaf
Copy link
Member

ocefpaf commented Oct 16, 2018

Thanks @talbertc-usgs! Awesome PR!! And thanks for @Conengmo for the nice review. This is a nice addition to folium 🎉

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.

4 participants