question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slow performance with many markers

See original GitHub issue

I have a dataset of about 10,000 markers. I am seeing unacceptable performance in all browsers.

Adding all the markers to the MarkerClusterGroup layer only takes about 100-200ms in all browsers, but adding the layer to the map itself takes about 7 seconds in Firefox 25. In Chrome, about 2 seconds. In Safari, about 4 seconds. I suspect IE would be much worse.

Also, it’s fairly slow when navigating. Very fast when zoomed way out, but closer to the city level, zooming and having the map repaint takes 1-2 seconds. Chrome is a bit smoother than FF/Safari.

I am seeing the same loading issue with the marker-clustering-realworld.10000.html example. The page takes several seconds to load. That demo seems to be a bit smoother to navigate, however, most likely because the data is less spread out.

Here is my marker data.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
danzelcommented, Nov 20, 2013

Just a quick one for now: One thing you can do to improve scrolling is to reduce the visible markers to just what is on screen:

var mcg = new L.MarkerClusterGroup(....);

//Remove everything outside the current view (Performance)
mcg._getExpandedVisibleBounds = function () {
    return mcg._map.getBounds();
};

By default we add markers/clusters for the visible screen + a screen worth on each side. This reduces it to just the visible screen (this happens on mobile by default, so should be no difference there)

Or you could increase maxClusterRadius so less clusters are created.

1reaction
Danielku15commented, Apr 26, 2018

Comment Deleted Looks like I accidentally posted my comment on the wrong issue, sorry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poor performance with many markers · Issue #6314 - GitHub
Solutions to have many markers work smoothly have already been invented. They say canvas-based markers is one of them: if that's true, ...
Read more >
Slow Performance for filtering markers in react-leaflet
I want to filter that data based on the markers in the viewport. My idea: Get the boundaries of the map and cross-check...
Read more >
Leaflet.markercluster Gives slow performance when zooming
I have used leaflet marker cluster to render the geojson. I am rendering 1 million geojson data. This gives better performance when render ......
Read more >
Performance – Markers (500+) showing up delayed / slowly
Hello there,. we are experiencing quite a delay from the inital page- / mapload to the markers showing up. We have around 500...
Read more >
Google Maps Platform best practices: Optimization and ...
So the takeaway here is to use raster images for better performance if you intend on putting a lot of markers on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found