showing results for - "distance to km javascript"
Gianluca
29 May 2017
1function calcCrow($lat1, $lon1, $lat2, $lon2){
2        $R = 6371; // km
3        $dLat = toRad($lat2-$lat1);
4        $dLon = toRad($lon2-$lon1);
5        $lat1 = toRad($lat1);
6        $lat2 = toRad($lat2);
7
8        $a = sin($dLat/2) * sin($dLat/2) +sin($dLon/2) * sin($dLon/2) * cos($lat1) * cos($lat2); 
9        $c = 2 * atan2(sqrt($a), sqrt(1-$a)); 
10        $d = $R * $c;
11        return $d;
12}
13
14// Converts numeric degrees to radians
15function toRad($Value) 
16{
17    return $Value * pi() / 180;
18}
19
similar questions
queries leading to this page
distance to km javascript