MarkerCluster and FeatureGroup don't work properly together.
See original GitHub issue
import pandas as pd
import folium
from folium.features import CustomIcon
from folium.plugins import MarkerCluster
df1 = pd.read_csv("/home/dominik/projekt/results/pkobp.csv")
df2 = pd.read_csv("/home/dominik/projekt/results/pekao.csv")
logo_PKOBP = 'https://upload.wikimedia.org/wikipedia/commons/8/8d/Logotyp_PKO_BP.svg'
logo_PEKAO = 'https://upload.wikimedia.org/wikipedia/commons/e/ee/Bank_Pekao_SA_Logo_%282017%29.svg'
frames = [df1, df2]
locationlist1 = df1[["Szerokość","Długość"]].values.tolist()
locationlist2 = df2[["Szerokość","Długość"]].values.tolist()
m = folium.Map(location=[52.2138, 20.9795], zoom_start=12, control_scale=True)
pkobp_layer = folium.FeatureGroup(name="PKO BP SA")
marker_cluster = MarkerCluster().add_to(pkobp_layer)
for point in range(len(locationlist1)):
PKOBP = folium.Marker(locationlist1[point], icon=CustomIcon(logo_PKOBP, icon_size=(40, 40))).add_to(marker_cluster)
pekao_layer = folium.FeatureGroup(name="PEKAO SA")
marker_cluster = MarkerCluster().add_to(pekao_layer)
for point in range(len(locationlist2)):
PEKAOSA = folium.Marker(locationlist2[point], icon=CustomIcon(logo_PEKAO, icon_size=(150, 22))).add_to(marker_cluster)
m.add_child(pkobp_layer)
m.add_child(pekao_layer)
m.add_child(folium.map.LayerControl())
m.save('/home/dominik/mapa1.html')
Problem description
I can’t use the MarkerCluster and LayerControl together. MarkerCluster groups separately the markers from PKOBP and PEKAOSA.
- Can someone tell me what is wrong in my code?
- Is it possible to change colors in MarkerCluster?
Expected Output
- I would like the markers to be grouped together. (the most important)
- If possible, I would like to change the colors, increase the number of shades.
Output of folium.__version__
print(folium.version) 0.5.0
Issue Analytics
- State:
- Created 6 years ago
- Comments:11
Top Results From Across the Web
Folium marker clusters not working as expected - Stack Overflow
I have a problem. I can't use the MarkerCluster and LayerControl together. I need to add the MarkerCluster to the following code but ......
Read more >Python folium markercluster doesn't work as expected for the ...
I would like to clusterize my points. Unfortunately I cannot do it with my code it loos like. import pandas as pd import...
Read more >Leaflet.markercluster | Marker Clustering plugin for Leaflet
Leaflet.markercluster. Provides Beautiful Animated Marker Clustering functionality for Leaflet, a JS library for interactive maps. Requires Leaflet 1.0.0.
Read more >How to provide marker clustering on the Leaflet map in the ...
In this text, I'm going to show you how you can achieve it in your Angular project using the Leaflet map with Leaflet.markercluster...
Read more >Examples of plugins usage in folium - | notebook.community
MarkerCluster. Adds a MarkerCluster layer on the map. ... To work properly in production, the connection needs to be encrypted (HTTPS), otherwise browser ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @dspyrhsu, good news, we very recently added a feature that should do just what you need. It is in #875 and is a plugin called
FeatureGroupSubGroup
. The second example in the docstring is I think what you need, ‘Multiple overlays part of the same cluster group’. Just make sure you get the most recent version of folium from the git master branch. Hope that helps.Hi,
Hi, You can see my final code at this link https://nbviewer.jupyter.org/urls/hugedot.pl/projekt_studia/projekt/wizualizacja/mapa.ipynb I hope you will find it useful.
Best regards, Dominik
W dniu czw., 10.09.2020 o 20:41 pabm1808 notifications@github.com napisał(a):