Reprint please specify the source http://blog.csdn.net/l1028386804/article/details/46970705
A snippet of code from Google Maps's script will probably be used. Let's see how it all counts.
Private static final Double Earth_radius = 6378.137;private static double rad (double D) {return d * math.pi/180.0;} public static double Getdistance (double lat1, double lng1, double lat2,double lng2) {Double radLat1 = rad (lat1);d ouble rad Lat2 = rad (LAT2);d ouble a = radlat1-radlat2;double B = rad (lng1)-Rad (lng2);d ouble s = 2 * Math.asin (MATH.SQRT (Math.pow (Math.sin (A/2), 2) + Math.Cos (RADLAT1) * MATH.COS (RADLAT2) * MATH.POW (Math.sin (B/2), 2))); s = s * earth_radius;s = Math. Round (S * 10000)/10000;return s;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java--Calculate distance by latitude and longitude of two points (episode)