Possible Duplicate:
How do I calculate distance between two latitude-longitude points?
How can I calculate the distance in meters between to geo locations in JavaScript? I found this answer but it is implemented in Java, and I did not really understand what was going on.
I am using HTML 5's geo location feature and using JavaScript to calculate the distance. Till now I have this function:
function calculateDistance(lat1, lat2, lng1, lng2)
{
return Math.sqrt(((lat1 + lat2)*(lat1 + lat2)) + ((lng1 + lng2)*(lng1 + lng2)));
}
Obviously this is not the value I require. Can anybody help me please?