通过经纬度计算两点间多距离

时间:2022-08-09 22:40:17

+(CGFloat)getDistanceFrom:(CLLocationCoordinate2D)from To:(CLLocationCoordinate2D)to

{

    double EARTH_RADIUS = 6371393;//地球半径 单位米


    CGFloat dis = sinf(from.latitude*M_PI/180)*sinf(to.latitude*M_PI/180)+cosf(from.latitude*M_PI/180)*cosf(to.latitude*M_PI/180)*cosf((from.longitude-to.longitude)*M_PI/180);

    dis = EARTH_RADIUS*acosf(dis);

    

    return dis;

}