ludo ludo - 1 month ago 10x
Objective-C Question

Retrieve UserLocation Coordinate with MapKit

I"m using MapKit in my application and disaply the user location with

[mapview setShowUserLocation:YES];

I want to set the and with the coordinate of the userLocation, how to do it?


Here is my answer, I try something like that and its working:

//inside my ViewDidLOad
locManager = [[CLLocationManager alloc] init];
[locManager setDelegate:self];
[locManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locManager startUpdatingLocation];

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation  {
CLLocationCoordinate2D loc = [newLocation coordinate]; [maptView setCenterCoordiante:loc]; }