I have code that gets user location and displays it on the mapView, but they have to zoom out and find themselves on the map, what I want is when the button is pressed it automatically takes them to where they are. Heres my code so far:
- (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;
}
Thanks for the help.
I would really appreciate some sample code.
If you want the the map to stay centered on user's location try this
[bombersMapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];