Leaflet / Leaflet.markercluster

Marker Clustering plugin for Leaflet
MIT License
3.98k stars 1k forks source link

Provide function to generate icon #1086

Open IanMayo opened 1 year ago

IanMayo commented 1 year ago

I'm plotting a map with lots of markers. For most of the time, the markers will be shown as clusters - so very few markers will actually be shown.

I think this offers a performance opportunity. If MarkerCluster took a function to generate the icon markers, then it would just call that function when a parent cluster got expanded. If clusters don't get expanded then the icon marker doesn't actually get created, which optimises performance and memory.

Note: the MarkerCluster would still need to know the coords of each icon, so I guess the developer would provide a coord/function pair for each icon.

IvanSanchez commented 1 year ago

You mean like https://github.com/Leaflet/Leaflet.markercluster#customising-the-clustered-markers ?

IanMayo commented 1 year ago

Hello Ivan, thanks for the prompt response :-)

You mean like https://github.com/Leaflet/Leaflet.markercluster#customising-the-clustered-markers ?

It's actually that code snippet that prompted the idea.

But, the function in the snippet provides the cluster icons (shaded circle with a number in the middle), not the icons themselves. So, we'll almost always have the cluster icons, it's the individual markers themselves that I'm hoping to defer.