1

My map is super fast and nice until I click my "houses for sale" layer, which adds less than 3,000 markers onto the map on its own L.layerGroup(). It really makes it difficult to zoom in/out and pan around. It's virtually unusable in this state. The second I click the layer away, it's again super fast. It's doubtlessly caused by the markers being rendered.

Why would less than 3,000 markers even make it go slower at all? Even a computer from the 1980s would be able to display such a small amount of markers on a map, no? And more importantly: how to fix it?

  • 3
    but your 80's computer wasn't using JavaScript in a browser – Ian Turton Mar 3 '18 at 10:43
3

It's just how Leaflet handles it. I'm not sure exactly, but perhaps it's because rendering is done on a single thread on the CPU? Not sure the specific reason, but if it was easy to fix it would have been fixed!

You can handle hundreds of thousands of points if you use the MarkerCluster plugin.

Or alternatively, you can load your data into Carto or MapBox and do it slightly differently. (They do server-side rendering of images, and provide a fast way to to interaction using UTF Grids.)

The third way of solving it is using MapBox GL (I think, I haven't tried this). I reckon MapBox GL will enable you to display a lot of points, and you then just need to work out how to transfer bulk data! But 3,000 points isn't a lot of data, so you would probably be fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.