我有获取用户位置并将其显示在 mapView 上的代码,但他们必须缩小并在地图上找到自己,我想要的是当按下按钮时它会自动将他们带到他们所在的位置。到目前为止,这是我的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
MKCoordinateRegion bombersRegion = { {0.0,0.0}, {0.0,0.0} };
bombersRegion.center.latitude = 42.812548;
bombersRegion.center.longitude = -73.940815;
bombersRegion.span.latitudeDelta = 0.01f;
bombersRegion.span.longitudeDelta = 0.01f;
[bombersMapView setRegion:bombersRegion animated:YES];
MapPin *ann = [[MapPin alloc] init];
ann.title = @"Bombers Burrito Bar";
ann.subtitle = @"447 State Street Schenectady, New York 12305";
ann.coordinate = bombersRegion.center;
[bombersMapView addAnnotation:ann];
}
-(IBAction)getLocation:(id)sender{
bombersMapView.showsUserLocation = YES;
}
谢谢您的帮助。
我真的很感激一些示例代码。