php - Get the list of all available coordinates by current coordinates
Get the solution ↓↓↓I am working on a project in which I have to find persons near me. I am able to get current coordinates. The problem is that I can't get the list of coordinates between radius of given kilometre. I got the script from Internet:
function twopoints_on_earth($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo)
{
$long1 = deg2rad($longitudeFrom);
$long2 = deg2rad($longitudeTo);
$lat1 = deg2rad($latitudeFrom);
$lat2 = deg2rad($latitudeTo);
//Haversine Formula
$dlong = $long2 - $long1;
$dlati = $lat2 - $lat1;
$val = pow(sin($dlati/2),2)+cos($lat1)*cos($lat2)*pow(sin($dlong/2),2);
$res = 2 * asin(sqrt($val));
$radius = 3958.756;
return ($res*$radius);
}
// latitude and longitude of Two Points
$latitudeFrom = 19.017656 ;
$longitudeFrom = 72.856178;
$latitudeTo = 40.7127;
$longitudeTo = -74.0059;
// Distance between Mumbai and New York
print_r(twopoints_on_earth( $latitudeFrom, $longitudeFrom,
$latitudeTo, $longitudeTo).' '.'miles');
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: attempt to read property "id" on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.