一,获取经纬度
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = @"我在这里";
self.tableView.hidden = YES;
// 定位经纬度
if ([CLLocationManager locationServicesEnabled]) {
NSLog(@"开始定位");
self.myLocationManager = [[CLLocationManager alloc] init];
self.myLocationManager.delegate = self;
[self.myLocationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters]; // 定位
[self.myLocationManager startUpdatingLocation]; // 开始定位
} else{
NSLog(@"Location services are not enabled");
}
}
#pragma mark - CLLocationManager delegate
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
[manager stopUpdatingLocation];
if (self.data == nil) {
float longitude = newLocation.coordinate.longitude; // 经度
float latitude = newLocation.coordinate.latitude; // 纬度
NSString *longstring = [NSString stringWithFormat:@"%f", longitude];
NSString *latitudestring = [NSString stringWithFormat:@"%f", latitude];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:latitudestring, @"lat", longstring, @"long", nil];
[self.sinaweibo requestWithURL:@"place/nearby_timeline.json"
params:params
httpMethod:@"GET"
block:^(id result) {
[self loadDataFinish:result];
}];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.title = @"我在这里";
self.tableView.hidden = YES;
// 定位经纬度
if ([CLLocationManager locationServicesEnabled]) {
NSLog(@"开始定位");
self.myLocationManager = [[CLLocationManager alloc] init];
self.myLocationManager.delegate = self;
[self.myLocationManager setDesiredAccuracy:kCLLocationAccuracyNearestTenMeters]; // 定位
[self.myLocationManager startUpdatingLocation]; // 开始定位
} else{
NSLog(@"Location services are not enabled");
}
}
#pragma mark - CLLocationManager delegate
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
[manager stopUpdatingLocation];
if (self.data == nil) {
float longitude = newLocation.coordinate.longitude; // 经度
float latitude = newLocation.coordinate.latitude; // 纬度
NSString *longstring = [NSString stringWithFormat:@"%f", longitude];
NSString *latitudestring = [NSString stringWithFormat:@"%f", latitude];
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:latitudestring, @"lat", longstring, @"long", nil];
[self.sinaweibo requestWithURL:@"place/nearby_timeline.json"
params:params
httpMethod:@"GET"
block:^(id result) {
[self loadDataFinish:result];
}];
}
}