ios 放大用户位置

ios zooming in on users location

您好,我已经将我的 MapKit 设置为显示用户位置,但它加载的视图缩小太多,所以我试图将其放大到例如20英里的区域。 我尝试使用其他一些问题的代码来做到这一点,但其中 none 似乎对视图产生了任何影响。 顺便说一句,我也在尝试查看当前用户:纬度和经度,但在我的浮点变量中只看到 0,也许这些是链接的?

代码如下:

- (void)viewDidLoad
{

#ifdef __IPHONE_8_0
    if(IS_OS_8_OR_LATER)
    {
        [self.locationManager requestWhenInUseAuthorization];
    }
#endif

    MKCoordinateSpan span = MKCoordinateSpanMake(20.5982f,0.0001f);
    CLLocationCoordinate2D coordinate = {30, 75};
    MKCoordinateRegion region = {coordinate, span};
    MKCoordinateRegion regionThatFits = [self.mapView regionThatFits:region];
    [self.mapView setRegion:regionThatFits animated:YES];

    self.locationManager.delegate=self;
   [self.locationManager startUpdatingLocation];

    float latitude = self.locationManager.location.coordinate.latitude;
    float longitude = self.locationManager.location.coordinate.longitude;

    [self.mapView.userLocation addObserver:self
                                forKeyPath:@"location"
                                   options:(NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld)
                                   context:NULL];
    self.mapView.showsUserLocation = YES;

非常感谢您为此提供的任何帮助。我是 MapKit 新手。

MKCoordinateSpan span = MKCoordinateSpanMake(30.5982f,0.0001f);
CLLocationCoordinate2D coordinate = {36, 90};
MKCoordinateRegion region = {coordinate, span};
MKCoordinateRegion regionThatFits = [self.mapView regionThatFits:region];
[self.mapView setRegion:regionThatFits animated:YES];