Baidu Geocoding API

如果要使用Baidu的Geocoding的API,需要引入百度官方的地图SDK,非常不方便,于是自己写了一个简单的只提供Geocoding的API。

github地址:https://github.com/barrycug/BaiduGeoCodingAPI

使用方法:

self.baiduGeoCoding = [[BaiduGeoCoding alloc]initWithKey:@"key"];
    [self.baiduGeoCoding geocoding:@"百度大厦" city:@"北京市" result:^(BaiduGeoCodingResult *result, NSError *error) {
        NSLog(@"x=%lf,y=%lf",result.location.coordinate.longitude,result.location.coordinate.latitude);
    }];
    
    
    CLLocation *loa = [[CLLocation alloc]initWithLatitude:39.983424 longitude:116.322987];
    [self.baiduGeoCoding reverseGeocoding:loa result:^(BaiduReverseGeoCodingResult *result, NSError *error) {
        NSLog(@"%@",result.formatted_address);
    }];
This entry was posted in iOS.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">