Finding Location in a Range

Standard

 

  1. Based on Haversine Formula – http://s.eamca.com/haversine-formula
  2. Implementation of Haversine on JavaScript – http://s.eamca.com/calculate-dist-lat-lng
  3. Using MySQL query – http://s.eamca.com/store-locator-with-php-mysql
    Search any point between 10Km from the center point 37,-122

    SELECT id, ( 6371 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 10 ORDER BY distance;

Leave a Reply