Use custom icons with canvas rendering leaflet

Viewed 5581

I need to draw thousands of points on a leaflet map with custom icons. The performance using the standard L.marker is too slow to be usable when I get to around 1500 markers. I attempted the solution here using L.circleMarker, and I am able to draw thousands of points with stellar performance. Unforunately, with using L.circleMarker I am only able to make different kinds of circles, which does not satisfy my requirements. I am also not able to leverage clustering, since there isn't a particularly good way to cluster these unrelated markers with different icons.

Is there a way to get the performance benefits of canvas rendering while being able to use custom icons?

5 Answers

Hi there use this node pakage, https://www.npmjs.com/package/leaflet-canvas-markers

By default, leaflet markers are added as individual DOM elements in our html page which is very hard to handel this much doms.

But this module use html canvas tag to plot markers on map.

Here is my canvas example for 10000 markers, the performnce is amazing but i did't use this package. But i will implement this in my project soon. This time i implemented canvas in some other way.

Demo -> https://parveen-sishodiya-git.github.io/on-demand-leaflet-markers/

Related