user1953744
user1953744

Reputation: 41

How can I set my mapview to automatically zoom in on user's current location?

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

Answers (3)

Carlos Vela
Carlos Vela

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

Nitin Alabur
Nitin Alabur

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

Craig
Craig

Reputation: 8304

[mapview setUserTrackingMode:MKUserTrackingModeFollow];

Upvotes: 0

Related Questions