記錄一下
百度地圖提供了一個(gè)方法:
BMKMapPointForCoordinate(CLLocationCoordinate2D?coordinate);
這個(gè)方法可以將經(jīng)緯度轉(zhuǎn)換為?直角地理坐標(biāo)
然后再通過(guò)另一個(gè)方法來(lái)計(jì)算距離:
CLLocationDistance?BMKMetersBetweenMapPoints(BMKMapPoint?a,BMKMapPoint?b);
返回的距離單位是米呢铆。
CLLocationCoordinate2D startCoor;
?startCoor.latitude=self.mapHelp.startlatitude; ?startCoor.longitude=self.mapHelp.startlongitude;
CLLocationCoordinate2D endCoor;
endCoor.latitude=self.detaiModel.reportlatitude;
endCoor.longitude=self.detaiModel.reportlongitude;
? ? ? ? ? ? CLLocationDistance dis;
? ? ? ? ? ? dis =BMKMetersBetweenMapPoints(BMKMapPointForCoordinate(startCoor),BMKMapPointForCoordinate(endCoor)) ;
這是我計(jì)算的當(dāng)前位置點(diǎn)和目的地位置的距離渠旁。