Ios 使用两个远点定义的半径绘制的MKCircle渲染不正确

Ios 使用两个远点定义的半径绘制的MKCircle渲染不正确,ios,mapkit,Ios,Mapkit,我已经创建了一个地图显示,绘制了2个点,并希望创建一个以其中一个点为中心的MKCircle,使圆的边缘通过另一个点。这应该与创建半径等于两个点之间距离的圆以及围绕其中一个点使圆居中一样简单。这在较小的距离上似乎效果很好,但在一定距离后,圆的半径不再与第二个点匹配。(在我的测试中,我在洛杉矶和纽约绘制了一个点) 我使用以下方法获取半径(米): CLLocationDistance dist = [loc1 distanceFromLocation:loc2]; NSLog(@"dist: %f",

我已经创建了一个地图显示,绘制了2个点,并希望创建一个以其中一个点为中心的MKCircle,使圆的边缘通过另一个点。这应该与创建半径等于两个点之间距离的圆以及围绕其中一个点使圆居中一样简单。这在较小的距离上似乎效果很好,但在一定距离后,圆的半径不再与第二个点匹配。(在我的测试中,我在洛杉矶和纽约绘制了一个点)

我使用以下方法获取半径(米):

CLLocationDistance dist = [loc1 distanceFromLocation:loc2];
NSLog(@"dist: %f", dist);
我用下列方法画圆:

MKCircle *circle = [MKCircle circleWithCenterCoordinate:coord1 radius:dist];
[circle setTitle:@"background"];
[mMapView addOverlay: circle];
MKCircle *circleLine = [MKCircle circleWithCenterCoordinate:coord2 radius:dist];
[circleLine setTitle:@"line"];
[mMapView addOverlay: circleLine];

这里有我遗漏的东西吗?这是相当令人沮丧的圆圈关闭,但只有一点点。在较小的距离上,我可以放大最大值,让大头针准确地接触到我的圆圈的外线。

问题可能是因为纽约和洛杉矶位于不同的纬度,一个以赤道为中心的半径为X米的圆圈在地图上比另一个靠近两极的半径相同的圆圈小。如果需要图片,请查看本页的第二张地图

那么如何获得正确的半径呢?如果您知道要显示的缩放级别,可以尝试以下(完全未经测试的)算法:

1. Convert the two geo-points to map points
2. Workout the distance in map points
3. use that distance to create a new map point at the same y coordinate offset from the center point (full left or full right won't matter)
4. convert this point to a geo-point
5. workout the distance between it at the center geo-point
6. use that as your radius.