I found a function in a PHP page that calculates the number of miles between 2 points, but it’s faulty. It’s supposed to work with google maps, but the difference in distances are ranging from 1.3 to 1.65 times further in google maps(which is more accurate).
Here’s the function:
$M = 69.09 * rad2deg(acos(sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($lon1 - $lon2))));
I find it to be a bit complicated and I don’t know that much about geometry to know wheter or not this is correct.
Can someone with a bit more knowhow take a look at this and see what’s wrong with it?
Maybe you are comparing the ‘distance as the crow flies’ (direct line between two points) with driving distance?
Also, see this post for calculating distance between two points in PHP.