I have a table where I store certain points of interest. Let's call them Skate parks for which I have the lat/long.
I would like to find all skate parks within a radius of X miles from a starting point with lat/long.
How would I do that?
I have a table where I store certain points of interest. Let's call them Skate parks for which I have the lat/long.
I would like to find all skate parks within a radius of X miles from a starting point with lat/long.
How would I do that?
Haversine formula. You get the distance of every park and return those that are within X.
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;
37 and -122 are the lat and lng of your "starting point" and 25 is X
This may help https://developers.google.com/maps/articles/phpsqlsearch_v3