Mouse Position plugin - #916
Conversation
| 'HeatMapWithTime', | ||
| 'MarkerCluster', | ||
| 'MeasureControl', | ||
| 'MousePosition', |
There was a problem hiding this comment.
E131 continuation line unaligned for hanging indent
indent position corrected
|
|
||
| https://github.com/ardhi/Leaflet.MousePosition | ||
|
|
||
| With the MIT License as below: |
There was a problem hiding this comment.
Good that you include the license. But could you put in in the file header? The docstring is converted to documentation and I don't want that littered with license texts.
| {% endmacro %} | ||
| """) # noqa | ||
|
|
||
| def __init__(self, position='bottomright', separator=' : ', emptyString='Unavailable', lngFirst=False, numDigits=5, |
There was a problem hiding this comment.
Please make this line 80 chars wide.
|
|
||
| Parameters | ||
| ---------- | ||
| position: location of the widget |
There was a problem hiding this comment.
Docstring convention is name, type and default value on the first line, description on the second. So something like:
position : str, default 'bottomright'
Location of the widget.
|
|
||
| def __init__(self, position='bottomright', separator=' : ', emptyString='Unavailable', lngFirst=False, numDigits=5, | ||
| lngFormatter=None, latFormatter=None, prefix=""): | ||
| """Coordinate, linear, and area measure control""" |
There was a problem hiding this comment.
No need for a docstring on a class init when you already have the docstring above.
|
Thanks for this PR, it's a useful plugin! Check out my review comments for some details. Here are some longer comments: Choose between specifying all arguments or using
The fact you only included Add an example Our current way of feature discovery is through an example gallery in Jupyter Notebooks. Please add an entry which shows how to use this plugin and its effect. Optionally add a test Not a strict necessity, but it would be nice if you can add a test for this module. You can check out the other plugin tests to see how they verify if the template is rendering correctly. Changelog Finally, just before merging, you should add a line in the changelog. Here's an example line from another plugin that was added:
|
Parameters doc string reformatted. Licence shifted to header. __init__ < 80 chars.
|
|
||
| from jinja2 import Template | ||
|
|
||
| class MousePosition(MacroElement): |
There was a problem hiding this comment.
E302 expected 2 blank lines, found 1
| ---------- | ||
| position : str, default 'bottomright' | ||
| Location of the widget. | ||
|
|
There was a problem hiding this comment.
W293 blank line contains whitespace
| {% endmacro %} | ||
| """) # noqa | ||
|
|
||
| def __init__(self, position='bottomright', separator=' : ', |
| """) # noqa | ||
|
|
||
| def __init__(self, position='bottomright', separator=' : ', | ||
| emptyString='Unavailable', lngFirst=False, |
|
|
||
| def __init__(self, position='bottomright', separator=' : ', | ||
| emptyString='Unavailable', lngFirst=False, | ||
| numDigits=5, lngFormatter=None, latFormatter=None, |
| emptyString='Unavailable', lngFirst=False, | ||
| numDigits=5, lngFormatter=None, latFormatter=None, | ||
| prefix=""): | ||
|
|
There was a problem hiding this comment.
W293 blank line contains whitespace
| ---------- | ||
| position : str, default 'bottomright' | ||
| Location of the widget. | ||
|
|
There was a problem hiding this comment.
W293 blank line contains whitespace
| emptyString='Unavailable', lngFirst=False, | ||
| numDigits=5, lngFormatter=None, latFormatter=None, | ||
| prefix=""): | ||
|
|
There was a problem hiding this comment.
W293 blank line contains whitespace
| empty_string='Unavailable', lng_first=False, | ||
| num_digits=5, lng_formatter=None, lat_formatter=None, | ||
| prefix=""): | ||
|
|
There was a problem hiding this comment.
W293 blank line contains whitespace
|
Finally got around to this: Choose between specifying all arguments or using kwargs Current convention in folium is to use Python style variable names throughout. That would mean that for example the arguments emptyString and lngFirst should become empty_string and lng_first up until they're added to the options dictionary. Any variable that's an explicit argument should also be listed in the docstring parameters. So apart from position the other arguments should also be listed. The fact you only included position in the docstring says something about the usefulness of the other arguments. You could decide to leave the other arguments out, and instead accept **kwargs and add those to the options. Then users can check out the original github project to see what those arguments are. Saves work, but is a bit lazy :) What do you want to do? Add an example Our current way of feature discovery is through an example gallery in Jupyter Notebooks. Please add an entry which shows how to use this plugin and its effect. Optionally add a test Not a strict necessity, but it would be nice if you can add a test for this module. You can check out the other plugin tests to see how they verify if the template is rendering correctly. Changelog Finally, just before merging, you should add a line in the changelog. Here's an example line from another plugin that was added: |
|
I made two changes:
Maybe you have anything to add to this? Otherwise I'll go merge this in a few days. |
| @@ -0,0 +1,120 @@ | |||
| # -*- coding: utf-8 -*- | |||
|
|
|||
| # CONVERTED TO PYTHON FROM: https://github.com/ardhi/Leaflet.MousePosition | |||
There was a problem hiding this comment.
You are using the plugin and not really converting it to Python.
I'm not a lawyer but I don't think this is necessary.
| 'if it is not in a Figure.') | ||
|
|
||
| figure.header.add_child( | ||
| JavascriptLink('https://cdn.rawgit.com/ardhi/Leaflet.MousePosition/c32f1c84/src/L.Control.MousePosition.js')) # noqa |
There was a problem hiding this comment.
We are already using noqa so no need for the extra line here.
I have just one monor comment about the license header added and I'm +1 to merge this. |
| """Add a field that shows the coordinates of the mouse position. | ||
|
|
||
| Uses the Leaflet plugin by Ardhi Lukianto under MIT license. | ||
| https://github.com/ardhi/Leaflet.MousePosition |
|
Thanks @btozer! |
Original plugin from: Ardhi Lukianto
https://github.com/ardhi/Leaflet.MousePosition
MIT Licence
Copyright 2012 Ardhi Lukianto