- (void)location{
self.locationManager.delegate = self;
//高精度定位
// 带逆地理信息的一次定位(返回坐标和地址信息)
[self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
// 定位超时时间,最低2s,此处设置为10s
self.locationManager.locationTimeout =10;
// 逆地理请求超时时间,最低2s,此处设置为10s
self.locationManager.reGeocodeTimeout = 10;
//获得返回的地址
[self.locationManager requestLocationWithReGeocode:YES completionBlock:^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error) {
if (error)
{
NSLog(@"locError:{%ld - %@};", (long)error.code, error.localizedDescription);
if (error.code == AMapLocationErrorLocateFailed) {
return;
}
}
NSLog(@"location:%@", location);
//得到定位的经纬度
CLLocationDegrees latitude = location.coordinate.latitude;
CLLocationDegrees longitude = location.coordinate.longitude;
NSLog(@"经度%f:",longitude);
NSLog(@"纬度%f:",latitude);
if (regeocode)
{
NSLog(@"reGeocode:%@", regeocode);
NSLog(@"reGeocode.cityName:%@", regeocode.city);
}
}];
}