6

I am using Leaflet to present around 90.000 data points. My test code is generated using the plugin QGIS2leaf in QGIS 10.10.1. I am using clustering and reviewing the code I can see that this is "leaflet.markercluster.js". In principle this works well.

enter image description here

For practical use I have a capacity problem. The clustering works fine when zooming in and out. The problem is that takes around 30 seconds before the map pops up. Some clients even crashes.

The reason for this seem to be transfer of the geojson file (dev tools confirms this). It is now at 12 MB down from 61MB. Removing all the attribute data evidently helped some.

I could probably remove some of the decimal numbers from the coordinates. But I would only gain a couple of percent.

How can I tweak this further:

  • Is there a way to transfer zipped geojson files to client (Leaflet).
  • The geojson file is mostly (70%) repeated text. Is there a way to transfer the coordinates and attributes without this overhead?
  • Can Leaflet do other formats which in this respect are more efficient?
2

This is the compromise between client-side and server-side data handling.

You can try using TopoJSON to make your file smaller, but it's a little tricky to run, and works better on polygons, including simplification.

I think you're best off using a server platform. CartoDB is free for small use like this, and it's got other advantages like fancy visualisation and styling and an awesome SQL API.

I built a visualisation using CartoDB and Leaflet that handles a large number of points here. I had wanted to use JSON and Leaflet clustering but the dataset was too big. My rule of thumb is more than ~1.5 MB and you don't want to be downloading it client-side any more!

If you're intent on doing it yourself, try TileJSON. I haven't had a go at getting it running, and you still need server-side processing.

  • Good advice - thank you. Have now played around with CartoDB and it looks ok. Incidentally I am also working with road accidents (animal roadkills). So your solution looks very relevant to our work. – ragnvald Aug 7 '15 at 11:16
2

Qgis2web can minify the GeoJSON. That will gain you a bit. It can also reduce the geometry precision - the number of decimal places (as qgis2leaf can).

Edit: qgis2web also supports scale-dependent visibility. Could this help?

  • Turns out it is not enough to get this thing up in the air using Leaflet. When the data has arrived in the clients end Leaflet does the job excellently. But the limit of objects (points) in my view goes around 10.000 points. – ragnvald Aug 7 '15 at 11:13
0

MarkerCluster is Limited to 50.000 points ,above that the Leaflet Client will slow down and the navigator may crash.

the Owner of Leaflet has developed a solution called Supercluster,that can cluster millions of points ,it is a Server-Side Solution with node.js and Client-Side in MapBox.

you can read about this Solution here

if you are unfamiliar with node.js, you can see here and here how you use Supercluster .

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.