question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MarkerCluster: icon_create_function is not inserted as function

See original GitHub issue

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 !

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
nakasixcommented, Sep 5, 2018

Hello,

Sorry for my absence, I confirm that it works with the master version.

Thank you,

0reactions
Conengmocommented, Sep 4, 2018

This has been fixed in #954. To use it you should install folium from the git master branch (until we release a next version). Thanks @nakasix for reporting this. By the way, if you have time maybe you can confirm it works now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Marker cluster leaflet : dynamically modify icon - Stack Overflow
My code works but doesn't do want I want : in the function iconCreateFunction I want to count markers of "ClusterBatterieFaible", but I...
Read more >
react-leaflet-markercluster | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Adding custom icons to L.markerClusterGroup?
Here's the rest of my code: var markerClusters = L.markerClusterGroup(); iconCreateFunction: function (cluster) { var markers ...
Read more >
Does Markercluster Work Together With Leafletproxy() And ...
I am trying to make leaflet markercluster plugin work with leafletProxy in an R Shiny app using the option iconCreateFunction. Is the plugin...
Read more >
How can i render 60000 accounts on leaflet map using ...
chunkInterval: 300, iconCreateFunction: function (cluster) { var childCount = cluster.getChildCount(); var c = ' marker-cluster-';
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found