我试图在 MKMapKit 中返回用户位置,但在 LOG 中,它总是返回 0.0000、0.0000。当项目运行时,它会在地图上显示 userLocation.. 但在日志显示 0、0..
有人知道怎么做吗?看看我的代码:
- (void)viewDidLoad
{ [超级 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;
}
谢谢!