PHP calculates the distance between two GPS points
Mysql calculates the distance between two GPS coordinates
javascript calculates the distance between two GPS points
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#lon is the longitude, lat is the latitude, don’t make a mistake ,$ lat1,$lon2,$lat2){ 2*ATAN2( SQRT(SIN(($lat1-$lat2)*PI( )/180 /2) lat2)*PI( )/ 180/2)+ lat2*PI()/ 180)*COS($lat1*PI() /180 ) (($lon1-$lon2)*PI()/ 180/2 *PI()/ 180/2)), SIN(($lat1 -$lat2 )*PI()/180/2) *SIN (($lat1-$lat2)* PI()/180 /2) +COS($lat2*PI()/180 )*COS( $ lat1*PI()/180) PI()/180 /2) $lon2)*PI ()/180/ 2))))*6378140; } Calling method: echo distance(39.91917,116.3896,39.91726,116.3940);1 echo
distance( 39.91917,116.3896 |
The above introduces PHP to calculate the distance between two GPS points, including the content. I hope it will be helpful to friends who are interested in PHP tutorials. |