使用反向地理编码提取街道名称(Google API)

时间:2013-07-21 15:31:04

标签: ios objective-c google-maps

我正在使用Google反向地理编码来获取用户的当前位置。我的代码是这样的:

    NSString* StrCurrentLongitude=[NSString stringWithFormat: @"%f", currentLocation.coordinate.longitude]; // string value

    NSString* StrCurrentLatitude=[NSString stringWithFormat: @"%f", currentLocation.coordinate.latitude];

    [NSURL URLWithString:[NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/geocode/json?latlng=%@,%@&sensor=true_or_false",StrCurrentLatitude,StrCurrentLongitude]];

现在我如何从这里继续获取用户的当前位置?

1 个答案:

答案 0 :(得分:1)

我头顶的

[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithUrl:yourURL] queue:[NSOperationQueue mainQueue] completion:^(NSURLResponse *r, NSData *d, NSError *e) {
    //decode it
    id json = [NSJSONSerialization JSONObjectWithData:d options:0 error:nil]; 

    //process google response, which is JSON IIRC
}];