美文网首页
根据经纬度拿反向地理编码(地址)

根据经纬度拿反向地理编码(地址)

作者: Axiba | 来源:发表于2016-06-23 13:55 被阅读112次
CLLocation *c = [[CLLocation alloc] initWithLatitude:lat longitude:lng];
        //创建位置
        CLGeocoder *revGeo = [[CLGeocoder alloc] init];
        //反向地理编码
        [revGeo reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
            if (!error && [placemarks count] > 0)
            {
                NSDictionary *dict = [[placemarks objectAtIndex:0] addressDictionary];
                NSLog(@"street address: %@",[dict objectForKey:@"Street"]);
                
            }
            else
            {
                NSLog(@"ERROR: %@", error);
            }
        }];

相关文章

网友评论

      本文标题:根据经纬度拿反向地理编码(地址)

      本文链接:https://www.haomeiwen.com/subject/mwondttx.html