/// <summary>
/// lat 纬度 lng 经度{ loc : { lon : 40.739037, lat: 73.992964 } }
/// </summary>
private
const
double
EARTH_RADIUS = 6378.137;
//地球半径
static
rad(
d)
{
return
d * Math.PI / 180.0;
}
public
GetdiqiuDistance(
lat1,
lng1,
lat2,
lng2)
radLat1 = rad(lat1);
radLat2 = rad(lat2);
a = radLat1 - radLat2;
b = rad(lng1) - rad(lng2);
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 * 100) / 100;
s;
Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有 粤ICP备16019765号