[GIS] Problem with performances with Leaflet in an Ionic app => interactive metro map

leafletmarkersmobile

I was hoping you could help me with something I am stuck with.
I am a newbie in the use of leaflet library on mobile and I encounter a problem with performances.

In fact, I try to build an app with an interactive metro map that might have 350 markers if not more. Because it is an image, not a map, my 350 markers are always displayed, no matter if it's zoomed in or zoomed out… and performances are impacted… It becomes VERY slow… 🙁

Does anyone have any clue to solve the issue?

Maybe a way to make markers appear only if they are in the area shown on the screen and disappear if they are out?

Best Answer

Keeping markers without canvas and without clustering will prevent you from any performance improvement at low zoom levels: when zoom is low enough to see your entire area, all your markers will be shown.

Stations may not be distinguishable one from another at low zoom levels (hence the rationale for using clustering in many situations).

Have you tried the canvas approach? You should realize that shapes (including L.circleMarker) are still click-able.

Demo: https://plnkr.co/edit/vqtHibiL8GZiPCd6L6gq?p=preview

(you can switch the map option preferCanvas to false to see the difference in performance with 500 circle markers based on canvas or SVG)