PHP计算两个GPS点之间的距离
Mysql计算两GPS坐标的距离
javascript计算两个GPS点之间的距离
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#lon为经度,lat为纬度,一定不要弄错了哦 functiondistance($lon1,$lat1,$lon2,$lat2){ return(2*ATAN2(SQRT(SIN(($lat1-$lat2)*PI()/180/2) *SIN(($lat1-$lat2)*PI()/180/2)+ COS($lat2*PI()/180)*COS($lat1*PI()/180) *SIN(($lon1-$lon2)*PI()/180/2) *SIN(($lon1-$lon2)*PI()/180/2)), SQRT(1-SIN(($lat1-$lat2)*PI()/180/2) *SIN(($lat1-$lat2)*PI()/180/2) +COS($lat2*PI()/180)*COS($lat1*PI()/180) *SIN(($lon1-$lon2)*PI()/180/2) *SIN(($lon1-$lon2)*PI()/180/2))))*6378140; } |
调用方法:
1 |
echo distance(39.91917,116.3896,39.91726,116.3940); |
以上就介绍了PHP计算两个GPS点之间的距离,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。