0

Just wondering how to work out distance between 2 latitude and longitude using PHP and Google Maps Api.

Any one got any idea or links to examples?

Jin Yong
  • 42,698
  • 72
  • 141
  • 187
  • http://stackoverflow.com/questions/2296087/using-php-and-google-maps-api-to-work-out-distance-between-2-post-codes-uk Does this help? – Ersel Aker Apr 05 '12 at 03:23

2 Answers2

1

Calculate distance between two points in google maps V3

I think you might be after something like this which has a few good answers.

Community
  • 1
  • 1
danski
  • 353
  • 3
  • 12
0
function calcDistance($lat1,$Lang1, $lat2, $Lang2)
{
    //RAD
    $b1 = ($lat1/180)*M_PI;
    $b2 = ($lat2/180)*M_PI;
    $l1 = ($Lang1/180)*M_PI;
    $l2 = ($Lang2/180)*M_PI;
    //equatorial radius
    $r = 6378.137;
    // Formel
    $e = acos( sin($b1)*sin($b2) + cos($b1)*cos($b2)*cos($l2-$l1) );
    return round($r*$e, 4);
}
foued611
  • 359
  • 2
  • 7