为什么MKCoordinateSpan会改变? [英] Why MKCoordinateSpan changes?

查看:122
本文介绍了为什么MKCoordinateSpan会改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我调试下面的代码时,我看到mapkit根据我提供的内容更改了span。 span2包含与提供的数字不同的数字。为什么会这样?

When I debug code below, I see that span is changed by mapkit from what I have provided. span2 contains different numbers from what was provided. Why is this happening?

- (void) viewDidLoad
{
    [super viewDidLoad];

    CLLocationCoordinate2D loc;
    loc.latitude = self.atm.lat;
    loc.longitude = self.atm.lon;

    MKCoordinateSpan span1 = MKCoordinateSpanMake(0.05f, 0.05f);
    self.mapView.region = MKCoordinateRegionMake(loc, span1);
    // at this point numbers are not 0.05 anymore
    MKCoordinateSpan span2 = self.mapView.region.span;
// ... more code
}


推荐答案

请注意,纬度和经度的变化不同,因此方形MapView实际上会显示其坐标具有不同跨度值的区域。这可能会导致您的mapview区域与您设置的范围不同(稍微?)。

Note that latitude and longitude change differently so square MapView will actually display region with different span values for its coordinates. This is likely to cause your mapview region to have span (slightly?) different from what you set.

在参考MKMapView的region属性时,有一些相关的短语:

In reference for MKMapView's region property there's somewhat relevant phrase:


仅更改该区域的中心坐标仍然可以
导致跨度隐式更改。
这是因为跨度所代表的
距离在不同纬度和经度
时改变
而地图视图可能需要调整
的跨度到占用新的
位置。

Changing only the center coordinate of the region can still cause the span to change implicitly. This is due to the fact that the distances represented by a span change at different latitudes and longitudes and the map view may need to adjust the span to account for the new location.

这篇关于为什么MKCoordinateSpan会改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆