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.

Fundamental performance problems with MarkerClusterer

See original GitHub issue

I have tried and failed to resolve performance problems with having many markers using the MarkerClusterer. I now believe that the performance issue is an architectural limitation caused by the fact that for each Marker a <div></div> is rendered and performance decreases lineairly with increasing numbers of markers.

The MarkerClusterer is intended to deal with many markers and it’s not working as advertised. I would recommend rewriting this and use the clusterer api more directly, avoiding a dom node for every marker. I can share the code I wrote based google-map-react as I was forced to move away from react-google-maps. Certainly not as elegant as it could be, but I was under a time crunch.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:7
  • Comments:8

github_iconTop GitHub Comments

7reactions
JvB94commented, Sep 6, 2018

Hi, I had the same problem. I was helped to hand over the prop “noRedraw” to the marker. The problem is that otherwise for every marker that is added or deleted the entire card is reloaded.

3reactions
aricciocommented, Aug 6, 2021

My own marker drawing code is a bit janky due to excessive reloads from the server, but it does seem like banning all redraws caused a bug where non-clustered points disappeared.

If you’re coming ere from google, what you actually probably want is to do something like this as long as you know how many markers you’re going to add ahead of time:

    let noClustererRedraw = undefined;
    if (index === (placesSize - 1)) {
        noClustererRedraw = false;
    }
    else {
        noClustererRedraw = true;
    }
    return (
        <Marker position={pos} key={/*code for key item*/} clusterer={clusterer} onClick={clickHandler} noClustererRedraw={noClustererRedraw} />
    )

Depending, of course, on your own personal code style preferences. I prefer if/else to inline ternary operators. In a language were function calls weren’t so miserably slow, I’d also factor that out to a function 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - Performance issues if MapComponent state is updated
I have a map with several thousand markers and I am using react-leaflet-markercluster for marker clustering. If I need to update a global...
Read more >
Performance issues with (clustered) point features
Therefore, I tried clustering using https://github.com/Leaflet/Leaflet.markercluster. There are still performance issues because all 2800 ...
Read more >
MarkerClusterer jump to zoom level on click issue
markerclusterer jumps to the next zoom level and shows the same cluster icon with the same number of markers. On the next click...
Read more >
Rethinking the usage and experience of clustering markers in ...
Therefore basic aggregation libraries using clustering methods were ... many others, considers only a subset of the performance issue – by ...
Read more >
Improving Google Maps Performance on Large Datasets
Feature image: Improving Google Maps Performance on Large Datasets ... + import MarkerClusterer from '@google/markerclustererplus';.
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