-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Added options for MarkerCluster and FastMarkerCluster #837
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
Added options for MarkerCluster and FastMarkerCluster #837
Conversation
@@ -1,6 +1,7 @@ | |||
# -*- coding: utf-8 -*- | |||
|
|||
from __future__ import (absolute_import, division, print_function) | |||
import json |
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 'json' imported but unused
# Conflicts: # folium/plugins/fast_marker_cluster.py
@@ -37,6 +37,9 @@ class FastMarkerCluster(MarkerCluster): | |||
Whether the Layer will be included in LayerControls. | |||
show: bool, default True | |||
Whether the layer will be shown on opening (only for overlays). | |||
options : dict, default None | |||
A dictionary with options for Leaflet.markercluster. See |
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.
W291 trailing whitespace
folium/plugins/marker_cluster.py
Outdated
icons: list of length n. | ||
Icon for each marker. | ||
options : dict, default None | ||
A dictionary with options for Leaflet.markercluster. See |
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.
W291 trailing whitespace
If there are no comments I'll merge this tomorrow. |
Popup for each marker. | ||
icons: list of length n. | ||
Icon for each marker. | ||
options : dict, default None |
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 look into a docstring template functionality to avoid these repetitions.
I believe pandas has a nice example of that, I'll look into it.
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 idea. I don't know how to do that yet, but I'm interested to know.
Let's try to avoid self-merges. You can assign me to review whenever you want. |
Alright will do! Thanks for the merge. |
Thanks for the PR! |
I added a way to provide the marker clusters with options. It's quite straight forward. Any options will work, I specifically needed it for
disableClusteringAtZoom
.The markerClusterGroup declaration in Javascript accepts an object with key/value pairs with options. I made the (Python) MarkerCluster and FastMarkerCluster to accept an
options
dictionary that gets json.dumped and given to the (Javascript) markerClusterGroup as argument.Since I was there, I also included the
icon_create_function
argument, since it belongs in options. I didn't include any checks on validity of the options, so that's on the user.