返回单位:米
static double Distance(double lon1, double lat1, double lon2, double lat2)
{
double R = 6378137; //地球半径
lat1 = lat1 * Math.PI / 180.0;
lat2 = lat2 * Math.PI / 180.0;
double sa2 = Math.Sin((lat1 - lat2) / 2.0);
double sb2 = Math.Sin(((lon1 - lon2) * Math.PI / 180.0) / 2.0);
return 2 * R * Math.Asin(Math.Sqrt(sa2 * sa2 + Math.Cos(lat1) * Math.Cos(lat2) * sb2 * sb2));
}
本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/archive/2012/12/10/2811318.html如需转载请自行联系原作者