<%
x1=39.9918928
y1=116.3099544
x2=41.8326865
y2=123.4038186
Const EARTH_RADIUS = 6378.137
Const Pi = 3.1415926535898
Function rad(d)
rad = d * Pi / 180
End Function
Function GetDistance(lat1, lng1, lat2, lng2)
Dim radlat1, radlat2
Dim a, b, s, Temp
radlat1 = rad(lat1)
radlat2 = rad(lat2)
a = radlat1 - radlat2
b = rad(lng1) - rad(lng2)
Temp = Sqr(Sin(a / 2) ^ 2 + Cos(radlat1) * Cos(radlat2) * Sin(b / 2) ^ 2)
s = 2 * Atn(Temp / Sqr(-Temp * Temp + 1))
s = s * EARTH_RADIUS
GetDistance = s
End Function
response.write GetDistance(x1,y1,x2,y2)
%>
感谢:http://hi.csdn.net/lzp4881