Return to Snippet

Revision: 43994
at April 4, 2011 23:23 by marzsman


Initial Code
function getDistanceBetweenPoints($latitude1, $longitude1, $latitude2, $longitude2) {
    $theta = $longitude1 - $longitude2;
    $distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) +
                (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) *
                cos(deg2rad($theta)));
    $distance = acos($distance);
    $distance = rad2deg($distance);
    $distance = ($distance * 69.09) * 1.609344;
    
    return (round($distance,2));
}

Initial URL


Initial Description
Get the distance between 2 points on a map

Initial Title
Get distance between 2 points

Initial Tags


Initial Language
PHP