ipyleaflet
ipyleaflet copied to clipboard
Can't create more than 1999 Markers consecutively
Hello Team,
I wanted to create a cluster with more than 4000 elements and the process was running slow (or infinite), anyway more than 30 secs. I ended up testing why it was fast earlier and I found an upper limit. Apparently you can make 1999 Markers in ~1.4 seconds but with 2000th the process runs to infinite.
count = 0
df_locations = pd.read_csv('/5000_locations.csv', sep=";")
for row_ in df_locations.iterrows():
location=(row_[1]['lat'],row_[1]['lon'])
Marker(location=location)
count +=1
if count == 1999:
break
Tested using Python 3.11 on VS Code Jupyter
For your use case, you should consider using MarkerCluster.
Hello @sackh , Thank you for the quick reply. But I still need to generate a list/tuple of markers, isn’t it?
From the suggested link:
marker1 = Marker(location=(48, -2))
marker2 = Marker(location=(50, 0))
marker3 = Marker(location=(52, 2))
marker_cluster = MarkerCluster(
markers=(marker1, marker2, marker3)
)
m.add_layer(marker_cluster);
@Matti88 yes you will need to create a list/tuple of Markers but you should not get performance issues with MarkerCluster.