Here is a function that I use to calculate the distance between two
points... I do not recall exactly where I found it

function CalculateDistance($lat1, $lon1, $lat2, $lon2){

  $R = 6371; // km
        $dLat = deg2rad($lat2-$lat1);
        $dLon = deg2rad($lon2-$lon1);
        $a = sin($dLat/2) * sin($dLat/2) +
          cos(deg2rad($lat1)) * cos(deg2rad($lat2)) *
          sin($dLon/2) * sin($dLon/2);
  $c = 2 * atan2(sqrt($a),  sqrt(1-$a));
  $d = $R * $c;
        return $d;
}

NB... distances are in km not miles.

Hope this helps,

Al


On Mon, Sep 29, 2008 at 11:52 AM, Mike Williams
<[EMAIL PROTECTED]> wrote:
>
> First obtain the lat/lng coordinates of the locations if you don't have
> them already.
>
> Then search for "Haversine formula" plus whatever language you are
> using. There are implementations of the Haversine formula in many
> different computer languages.
>
> --
> http://econym.org.uk/gmap
> The Blackpool Community Church Javascript Team
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to