-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Re-factor Circle and CircleMarker #683
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
The fill opacity of the marker, between 0. and 1. | ||
popup: string or folium.Popup, default None | ||
Input text or visualization for object. | ||
|
||
See http://leafletjs.com/reference-1.2.0.html#path for more otions. |
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.
Instead of overloading the docstring I'll leave only the main options here and refer to the original page for more.
def __init__(self, location, radius=10, popup=None, **kw): | ||
super(Circle, self).__init__(_validate_location(location), popup=popup) | ||
self._name = 'circle' | ||
options = _parse_path(**kw) |
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 don't want to make this overly complex. Just a simple function to parse the options.
Ideally this function could validade the options as well.
options = _parse_path(**kw) | ||
|
||
options.update({'radius': radius}) | ||
self.options = json.dumps(options, sort_keys=True, indent=2) |
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.
First step towards a cleaner HTML. I want to eliminate blank spaces and bad indentations.
} | ||
) | ||
.addTo({{this._parent.get_name()}}); | ||
{{ this.options }} |
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.
We should use json.dumps
everywhere to reduce the amount of code like 'true' if something else 'false'
.
weight: int, default 2 | ||
Stroke weight in pixels | ||
fill_color: str, default 'black' | ||
fill: bool, default 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.
That is different from the current defaults! Here I applied leaflet's defaults everywhere.
@@ -1,6 +0,0 @@ | |||
var {{ circle }} = L.circleMarker([{{ lat }}, {{ lon }}], { |
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.
First step to eliminate all these render templates.
assert circle.get_bounds() == expected_bounds | ||
assert json.dumps(circle.to_dict()) == circle.to_json() | ||
assert circle.location == [-27.551667, -48.478889] | ||
assert circle.options == json.dumps(options, sort_keys=True, indent=2) |
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.
We should follow this example to re-factor the tests in features.py
.
* refactor circle * add tests * fix typo * update changelog
This PR is the first of many that:
Path
)If this works nicely I plan to do the same for all
feature.py
.Closes #430, #524, and #569