[GIS] Large loads geojson from thesql to leaflet

geojsonleafletMySQLPHP

I have a mysql database with +25K rows including geometry and other attributes.
Using a mysql2geojson php script I then added it to a leaflet map.

It is super slow now, what can I do to boost the performance?

I'm using www.one.com as host meaning I dont have access to anything else than php/mysql. I can't get postgis/geoserver, etc.

I also intend to design a search filter limiting which points to be shown on the map. For this purpose, is it best to do new calls to the database, or should I be working against a "local dump" for the searching?

To summarize I wonder how to best work with big point data sets with mysql/php/leaflet including searching. Any tips are welcome!

Best Answer

Here are a couple of thoughts on what you can do to boost performance:

  1. Send a BBox to server and return only points within it
  2. Use a library like turf.js http://turfjs.org/ on the client to only draw points within the maps current BBox
  3. Marker Clustering https://github.com/Leaflet/Leaflet.markercluster
  4. Use SVG icons instead of images
  5. Only return geometry and unique identifier of points, than send a query to the server to get the details for that point. This will decrease the initial load of your json file and memory stored on the client.
  6. Use web workers to download the json while running other functions

Ideally you would generate tiles for this large of a load, but the previous pointers should help guide to better performance.