Skip to content

MarkerCluster: icon_create_function is not inserted as function #945

Description

@nakasix

Hello,

I have a problem with my generation of map. In fact, I obtain double quotes in my source code, so I get "this._group.options.iconCreateFunction is not a function" message in Firefox.

Sample of my script :

# Create Map
obj_map_cluster = folium.Map(
    # Latitude and Longitude of Map (Northing, Easting)
    location=[46.5286, 2.4389],
    # Forces Leaflet to use the Canvas back-end for vector layers instead of SVG
    prefer_canvas=True,
    # Map tileset to use
    tiles='cartodbdark_matter',
    # Initial zoom level for the map
    zoom_start=6
)

# Assign icon create function
obj_markercluster = plugins.MarkerCluster(
    icon_create_function="""
function (cluster) {
    return L.divIcon({ html: cluster.getChildCount(), className: 'mycluster', iconSize: L.point(40, 40) });
}
"""
)

# Create Marker
obj_marker = folium.Marker([DEFINITION OF MARKER])
obj_markercluster.add_child(obj_marker)
obj_markercluster.add_to(obj_map_cluster)
obj_map_cluster.save('sites_cluster.html')

Problem description

HTML source code is :
"iconCreateFunction": "function (cluster) {\n return L.divIcon({ html: cluster.getChildCount(), iconSize: L.point(40, 40) });\n}"

Expected Output

To work, I would like :
iconCreateFunction: function (cluster) { return L.divIcon({ html: cluster.getChildCount(), iconSize: L.point(40, 40) });}

Without '"' and '\n'

Output of folium.__version__

My version is 0.6.0+11.g71ab988

Thank you !

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn issue describing unexpected or malicious behaviour

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions