Skip to content

Fix icon_create_function in MarkerCluster #954

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

Merged
merged 3 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Bug Fixes

- Fix wrong default value for fmt argument of WmsTileLayer (conengmo #950)
- Fix icon_create_function argument in MarkerCluster (conengmo #954)


0.6.0
Expand Down
9 changes: 7 additions & 2 deletions folium/plugins/marker_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class MarkerCluster(Layer):
_template = Template(u"""
{% macro script(this, kwargs) %}
var {{this.get_name()}} = L.markerClusterGroup({{ this.options }});
{%- if this.icon_create_function is not none %}
{{ this.get_name() }}.options.iconCreateFunction =
{{ this.icon_create_function.strip() }};
{%- endif %}
{{this._parent.get_name()}}.addLayer({{this.get_name()}});
{% endmacro %}
""")
Expand All @@ -73,9 +77,10 @@ def __init__(self, locations=None, popups=None, icons=None, name=None,
self.add_child(Marker(location, popup=p, icon=i))

options = {} if options is None else options
if icon_create_function is not None:
options['iconCreateFunction'] = icon_create_function.strip()
self.options = json.dumps(options, sort_keys=True, indent=2)
if icon_create_function is not None:
assert isinstance(icon_create_function, str)
self.icon_create_function = icon_create_function

@staticmethod
def _validate(obj, cls):
Expand Down