传递参数:
地址1纬度: $lat1,经度: $lng1,
地址2的纬度$lat2、经度: $lng2、
示例:
封装方法:
/** *个纬度与经度的距离*/publicfunctiongetdistance ($ la t1、$lng1、$lat2、$lng2) ) { $earthRadius=6367000; //approximateradiusofearthinmeters $ la t1=($ la t1 * pi ) )/180; $LNG1=($LNG1*pi ) ) ) )/180; $lat2=($lat2*pi ) ) )/180; $LNG2=($LNG2*pi ) ) ) )/180; $calcLongitude=$lng2 - $lng1; $calcLatitude=$lat2 - $lat1; $Stepone=pow(sin ) $calclatitude/2 )、2 ) cos ) $laT1 )、cos ) $laT2 )、pow ) sin ) $calclongitude/2 )、2; $steptwo=2*Asin(min(1,sqrt ) $Stepone ); $ calculated distance=$ earth radius * $ step two; 返回旋转($ calculated distance; }