Determining Midpoint Between 2 Coordinates

后端 未结 5 1435
深忆病人
深忆病人 2020-12-15 04:55

I am trying to determine the midpoint between two locations in an MKMapView. I am following the method outlined here (and here) and rewrote it in Objective-C,

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-15 05:31

    Just a hunch, but I noticed your lon2 and lat2 variables are being computed with M_PI/100 and not M_PI/180.

    double lon1 = _lo1.longitude * M_PI / 180;
    double lon2 = _loc2.longitude * M_PI / 100;
    
    double lat1 = _lo1.latitude * M_PI / 180;
    double lat2 = _loc2.latitude * M_PI / 100;
    

    Changing those to 180 might help you out a bit.

提交回复
热议问题