This seems like very basic question but I didnt find anything, and I have tried all!! I just want to make a button to zoom in into users location! This is what I've got so far:
CLLocationCoordinate2D userLocationCoordinate;
- (void)viewDidLoad {
[super viewDidLoad];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
[self.locationmanager requestWhenInUseAuthorization];}
[locationManager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"OldLocation %f %f", oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
NSLog(@"NewLocation %f %f", newLocation.coordinate.latitude, newLocation.coordinate.longitude);
userLocationCoordinate.latitude = newLocation.coordinate.latitude;
userLocationCoordinate.longitude = newLocation.coordinate.longitude;
}
-(IBAction)showUserLocation:(id)sender{
[self.mapview setCenterCoordinate:userLocationCoordinate animated:YES];
}
Please I need help, If theres a way in which I dont use CLLocationManager
it would be better.
Thanks.