Fra*_*xis 11 iphone google-maps geolocation mapkit ios
我实际上是在计算x和y坐标中最大和最小点之间的距离MKMapPoints
.
为此,我这样做(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);
Run Code Online (Sandbox Code Playgroud)
我在控制台中得到18997878.291251.但是当我将距离计算更改为:
dist = MKMetersBetweenMapPoints(test1, test2);
Run Code Online (Sandbox Code Playgroud)
我得到18873651.664238,所以我不明白有什么区别.我甚至不知道我是否做正确的事情来获得x和y轴的最大距离值.
任何帮助将不胜感激.
我猜这是一个算法问题。当达到一定精度时停止的某种近似。这就是为什么那里没有换向的原因。您可以尝试示例代码来获取地图上两点之间的距离,而无需使用 MKMapPoints:
\n\n- (float) distanceToLPU {\n\n useDelegate\n\n CLLocationCoordinate2D pointACoordinate = appDelegate.usrLoc;\n CLLocation *pointALocation = [[CLLocation alloc] initWithLatitude:pointACoordinate.latitude longitude:pointACoordinate.longitude];\n\n CLLocationCoordinate2D pointBCoordinate;\n pointBCoordinate.latitude = [self.latitude doubleValue];\n pointBCoordinate.longitude = [self.longitude doubleValue];\n\n CLLocation *pointBLocation = [[CLLocation alloc] initWithLatitude:pointBCoordinate.latitude longitude:pointBCoordinate.longitude]; \n\n float distanceMeters = [pointALocation distanceFromLocation:pointBLocation]; \n\n [pointALocation release];\n [pointBLocation release]; \n\n NSString *dist = [NSString stringWithFormat:@" (%.0f \xd0\xbc)", distanceMeters];\n NSLog(@"Distance to this LPU:%@", dist);\n\n return distanceMeters;\n }\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
1419 次 |
最近记录: |