When loading the markers for the map we load ALL the markers then iterate and keep the ones that are in the radius. This won't scale so we just need to change how we fetch the markers. I suggest using a raw sql query to fetch them. I've used a similar query for other projects to success.
Example
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance
FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;
Yea you can hard-code queries with cakephp pretty easily, and there shouldn't be security concerns with this since there's no user input involved. This is a much better solution.
When loading the markers for the map we load ALL the markers then iterate and keep the ones that are in the radius. This won't scale so we just need to change how we fetch the markers. I suggest using a raw sql query to fetch them. I've used a similar query for other projects to success.
Example
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 25 ORDER BY distance LIMIT 0 , 20;
http://stackoverflow.com/a/574736/1149601
Not exactly sure how to implement this using cakephp's helpers yet.