我有问题。我无法一起使用MarkerCluster和LayerControl。我需要将MarkerCluster添加到以下代码中,但遗憾的是仍然无法正常工作。谁能告诉我怎么做?
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')