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

+(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;

}

posted @ 2015-07-03 16:35  李伯波  阅读(243)  评论(0编辑  收藏  举报