MapView regionThatFits使用horizo​​ntalAccuracy设置

时间:2011-05-02 07:48:43

标签: iphone objective-c cocoa-touch mkmapview cllocation

我正在寻找一种将米转换为mapview区域的方法。

CLLocation的{​​{1}}是一个双精度数,表示以米为单位的精确度。 horizontalAccuracyregionThatFits: MKCoordinateRegion spanlongitudeDelta。如何将米转换为经度/纬度范围?

1 个答案:

答案 0 :(得分:2)

找到答案。似乎1度纬度等于111公里左右,或111120米

- (MKCoordinateRegion)regionForAccuracyOfLocation:(CLLocation *)location
{
    CLLocationDegrees spanInDegrees = (CLLocationDegrees) (location.horizontalAccuracy / 222240);

    MKCoordinateSpan span = MKCoordinateSpanMake(spanInDegrees, spanInDegrees) ;
    CLLocationCoordinate2D coordinate = location.coordinate;
    MKCoordinateRegion region = MKCoordinateRegionMake(coordinate, span);

    return region;
}