如何设置我的mapview以自动放大用户的当前位置?

时间:2013-01-14 03:39:24

标签: xcode location mkmapview zoom

当我点击标签栏中的“地图”按钮时,它会拉起我的地图视图控制器,并在地图视图上显示用户的当前位置(我使用以下代码):

[mapview setShowsUserLocation:YES];

超级简单。但是,如果我希望地图自动放大用户的当前位置,我该怎么做呢(在xCode中)?

谢谢:)

3 个答案:

答案 0 :(得分:8)

我认为这就是你需要的

  - (void)viewDidLoad
 {
    [super viewDidLoad];
    self.mapView.showsUserLocation=YES;
    self.mapView.delegate = self;
    [self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
    //some code
 }

答案 1 :(得分:0)

[mapview setUserTrackingMode:MKUserTrackingModeFollow];

答案 2 :(得分:0)

这应该做你想要的

    MKCoordinateRegion region;

    region = (MKCoordinateRegion){(current user location).location.coordinate, (current user location).locationCoordinateSpan};        
    [theMapView setRegion:region animated:NO/YES];
相关问题