Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient way of accessing large data sets to display on Leaflet

Tags:

leaflet

I have a global database of objects (points on a map) that I would like to show on a Leaflet map. Instead of loading all the database (simply too big) at once and creating the objects on a Leaflet LayerGroup, is there a more efficient way to go about querying data, perhaps as each map tile loads, or am I looking at creating a custom solution for this?

like image 701
CuNimb Avatar asked Mar 22 '13 09:03

CuNimb


Video Answer


1 Answers

You could watch the 'moveend' event on map with map.on('moveend',loadstuff), make an ajax call inside loadstuff() to grab markers inside the current map.getBounds(), and then add/remove markers(I would assume you have some sort of global identifier for each of them) whether they are inside or outside the current view.

like image 115
snkashis Avatar answered Oct 18 '22 21:10

snkashis