Large loads geojson from mysql to leaflet?

by Anders   Last Updated April 01, 2018 09:22 AM

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 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!

Answers 3

You might try a clustering strategy such as the Leaflet Marker Clustering plugin -

You can see an example of this at work here -

Another strategy (although maybe not feasible given your constraints) would be to create map tiles using something like TileMill with UTFGrids for mouse events / discoverability.

April 23, 2014 21:14 PM

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 on the client to only draw points within the maps current BBox
  3. Marker Clustering
  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.

January 24, 2015 00:35 AM

maybe we can use mysql index to load 1000 rows each at a time..Logically its almost same as map tiling

Jubin Roy
Jubin Roy
April 01, 2018 08:55 AM

Related Questions

MySQL to GeoJSON - Formatting Issue

Updated December 18, 2016 08:09 AM

load GeojSON generate from MySQL with PHP

Updated January 19, 2019 18:22 PM

How to generate geoJSON file from mysql table?

Updated October 03, 2016 08:09 AM

MySQL GeoJSON query for polygons format error

Updated January 23, 2018 22:22 PM