Distance between two latitude/longitudes
Usually, the great circle distance is used to find the distance between two points on the Earth’s surface. This method is only an approximation (with errors being less than 0.5% according to Wikipedia) because the Earth is not a perfect sphere.
Vincenty solutions of geodesics on the ellipsoid demonstrates superior approximations (errors less than 1mm), with sample code in Java and Javascript. Wikipedia also has an article on Vincenty’s formulas.