$distance = (20); // value is km convent 1 miles = 1.60934 km
$radius = 6371;
$maxlat = $latitude + (($distance / $radius) * 180.0 / M_PI);
$minlat = $latitude - (($distance / $radius) * 180.0 / M_PI);
$maxlng = $longitude + (($distance / $radius / cos($latitude * M_PI /180.0)) * 180.0 / M_PI);
$minlng = $longitude - (($distance / $radius / cos($latitude * M_PI /180.0)) * 180.0 / M_PI);
Use Query--->>
SELECT * FROM table_name WHERE latitude BETWEEN $minlat AND $maxlat AND longitude BETWEEN $minlng AND $maxlng
$radius = 6371;
$maxlat = $latitude + (($distance / $radius) * 180.0 / M_PI);
$minlat = $latitude - (($distance / $radius) * 180.0 / M_PI);
$maxlng = $longitude + (($distance / $radius / cos($latitude * M_PI /180.0)) * 180.0 / M_PI);
$minlng = $longitude - (($distance / $radius / cos($latitude * M_PI /180.0)) * 180.0 / M_PI);
Use Query--->>
SELECT * FROM table_name WHERE latitude BETWEEN $minlat AND $maxlat AND longitude BETWEEN $minlng AND $maxlng
No comments:
Post a Comment