# Your code here
map2 = folium.Map(location=[53.232350, -1.422151], tiles='CartoDB dark_matter', zoom_start=11)
marker_cluster = folium.MarkerCluster().add_to(map2)
for point in range(0, len(locationlist)):
folium.Marker(locationlist[point], popup=df_counters['Name'][point]).add_to(marker_cluster)
map2
When I try to run the above code, I get the following error.
[this should explain why the current behavior is a problem and what is the expected output.]
folium.__version__AttributeError Traceback (most recent call last)
6 map2 = folium.Map(location=[53.232350, -1.422151], tiles='CartoDB dark_matter', zoom_start=11)
7
----> 8 marker_cluster = folium.MarkerCluster().add_to(map2)
9
10 for point in range(0, len(locationlist)):
AttributeError: module 'folium' has no attribute 'MarkerCluster'
You seem not to have imported the plugins module:
from folium.plugins import MarkerCluster
To clarify, MarkerCluster is a plugin and is not available in the main folium module. So you cannot use it as folium.MarkerCluster. Instead you have to import the plugins and get it from there. Two options:
import folium.plugins
folium.plugins.MarkerCluster()
or
from folium.plugins import MarkerCluster
MarkerCluster()
I'm closing the issue. Feel free to add comments with additional questions of info. We can reopen the issue if needed.
hi @Conengmo ! I have imported the plugins but I keep receiving the following message:
"Exception has occurred: AttributeError
module 'folium' has no attribute 'MarkerCluster'"
appreciate your help!
Can you share a code snippet?
Can you share a code snippet?
Thank you for your help, but I just solved the problem!
Also, I need to say that your Github's files have been very helpful! I am just a beginner with Python, and I have found a lot of useful info in your account and your comments. Thank you so much!
@barbaramchd good to hear you solved it, and thanks for the kind words :)
@barbaramchd Hola, C贸mo lo resolviste???
Most helpful comment
To clarify,
MarkerClusteris a plugin and is not available in the main folium module. So you cannot use it asfolium.MarkerCluster. Instead you have to import the plugins and get it from there. Two options:or
I'm closing the issue. Feel free to add comments with additional questions of info. We can reopen the issue if needed.