I`m trying to return the user location in MKMapKit, but at LOG, it returns always 0.0000, 0.0000. when the project run, it shows the userLocation at map.. but at log show 0, 0..
some body know how to do it? take a look in my code:
- (void)viewDidLoad
{
[super viewDidLoad];
//esconder navBar
[[self navigationController] setNavigationBarHidden:YES animated:NO];
mapView.showsUserLocation = YES;
double lat = -21.21258;
double lng = -47.816802;
CLLocationCoordinate2D Coordinate;
NSLog(@"%f , %f", mapView.userLocation.coordinate.longitude, mapView.userLocation.coordinate.latitude);
Coordinate.latitude = lat;
Coordinate.longitude = lng;
MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
annotationPoint.coordinate = Coordinate;
annotationPoint.title = @"Ribeirão Shopping";
annotationPoint.subtitle = @"Ribeirão Preto - SP";
[self.mapView addAnnotation:annotationPoint];
MKCoordinateRegion newRegion;
newRegion.center.latitude = lat;
newRegion.center.longitude = lng;
[self.mapView setRegion:newRegion animated:YES];
mapView.mapType = MKMapTypeStandard;
}
thanks!
finding user location for mapview does takes some time so give it some time before using
mapView.userlocaitongit it a few seconds ~3 and then try to log the user location. I’m sure you will get it there.