Reputation: 41
When I click on the "Map" button in my tab bar, it pulls up my Map View Controller, and shows the user's current location on the mapview (I'm using the following code):
[mapview setShowsUserLocation:YES];
Super easy. But if I want the map to automatically zoom in on the user's current location, how do I go about doing this (in xCode)?
Thanks :)
Upvotes: 2
Views: 7080
Reputation: 253
i think this is what you need
- (void)viewDidLoad
{
[super viewDidLoad];
self.mapView.showsUserLocation=YES;
self.mapView.delegate = self;
[self.mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
//some code
}
Upvotes: 8
Reputation: 5812
this should do what you are looking for
MKCoordinateRegion region;
region = (MKCoordinateRegion){(current user location).location.coordinate, (current user location).locationCoordinateSpan};
[theMapView setRegion:region animated:NO/YES];
Upvotes: 0