11
我實際上試圖計算MKMapPoints
的x和y座標中最大和最小點之間的距離。爲什麼MKMetersBetweenMapPoints在交換參數時會給我不同的結果?
對於這一點,我這樣做(在y軸的最大距離):
MKMapPoint test1, test2;
double dist;
test1.x = 0.0;
test1.y = 0.0;
test2.x = 0.0;
test2.y = MKMapSizeWorld.height;
dist = MKMetersBetweenMapPoints(test2, test1);
NSLog(@"Distance %f",dist);
我在控制檯中看到18997878.291251。但是當我改變距離計算爲:
dist = MKMetersBetweenMapPoints(test1, test2);
我得到18873651.664238,所以我不明白有什麼區別。我甚至不知道我是否做了正確的事情來獲得x和y軸上距離的最大值。
任何幫助將不勝感激。
相關:http://stackoverflow.com/questions/5558854/order-of-cllocation-objects-in-distancefromlocation – Anna 2012-01-11 14:55:43
應日誌行是 NSLog(@「Distance%f」,dist); – Damo 2012-01-11 15:36:10
對不起,是一個錯字。變量名稱是dist。 (更正) – FranciscoAlexis 2012-01-11 18:24:22