转载自:http://www.cnblogs.com/qdwyg2013/p/5594002.html
** * Created by silly on 2017/7/12. */ public class GetDistance { /** * 计算两点之间真实距离 * @return 千米(km) */ public static double getDistance(double longitude1, double latitude1, double longitude2, double latitude2) { // 纬度 double lat1 = (Math.PI / 180) * latitude1; double lat2 = (Math.PI / 180) * latitude2; // 经度 double lon1 = (Math.PI / 180) * longitude1; double lon2 = (Math.PI / 180) * longitude2; // 地球半径 double R = 6371; // 两点间距离 km,如果想要米的话,结果*1000 double d = Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1)) * R; return d; } }