百度地图开发之计算两点之间的距离

pk = 180 / 3.14169  
a1 = lat_a / pk  
a2 = lng_a / pk  
b1 = lat_b / pk  
b2 = lng_b / pk  
t1 = math.cos(a1) * math.cos(a2) * math.cos(b1) * math.cos(b2)  
t2 = math.cos(a1) * math.sin(a2) * math.cos(b1) * math.sin(b2)  
t3 = math.sin(a1) * math.sin(b1)  
tt = math.acos(t1 + t2 + t3)  
return 6366000 * tt  
posted @ 2016-09-02 15:04  newcaoguo  阅读(5196)  评论(0编辑  收藏  举报