ipyleaflet icon indicating copy to clipboard operation
ipyleaflet copied to clipboard

Can't create more than 1999 Markers consecutively

Open Matti88 opened this issue 2 years ago • 3 comments

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

Matti88 avatar Jan 15 '23 01:01 Matti88

For your use case, you should consider using MarkerCluster.

sackh avatar Jan 15 '23 07:01 sackh

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 avatar Jan 15 '23 19:01 Matti88

@Matti88 yes you will need to create a list/tuple of Markers but you should not get performance issues with MarkerCluster.

sackh avatar Jan 21 '23 07:01 sackh