The issue I am facing is with the loading time. I am building an application to show trees of a city on a leaflet map. The trees are getting loaded as the map pans, on a particular zoom level. Locations having about 2000 trees get loaded fast enough. But there are some locations where the density of trees is too high. So as soon as I pan to that location, it takes a while to load up the data. Is there any way I could reduce the loading time? The query I am using to fetch data at a particular distance from the center of the viewport is,
SELECT gt.latitude_dl, gt.longitude_dl, t.name_vc,
p.project_vc, gt.height_dc, gt.age_dc, gt.address_txt, gt.canopy_diameter_dc, o.ownership_vc,
c.condition_vc, gt.remark_txt,
SQRT(
POW( 69.1 * ( gt.latitude_dl - [ center_lat ] ), 2) +
POW( 69.1 * ( [ center_lon ] - gt.longitude_dl ) * COS( gt.latitude_dl / 57.3 ), 2 )
) AS distance
FROM tree_geotags_t gt
LEFT JOIN mst_tree_t t ON t.tree_id = gt.tree_id
LEFT JOIN mst_project_t p ON p.project_id = gt.project_id
LEFT JOIN mst_tree_condition_t c ON c.tree_condition_id = gt.tree_condition_id
LEFT JOIN mst_ownership_type_t o ON o.ownership_type_id = gt.ownership_type_id
HAVING distance < 0.4 ORDER BY distance
Where [ center_lon ] and [ center_lat ] are the viewport center coordinates I am passing via ajax.