在使用百度地图时,严格按照百度文档做的,通过搜索获取了检索的地址列表之后,取得了当前选择地址行的坐标(经纬度),但是通过输入经纬度去获得具体地址信息时,返回的地址信息是空,在确定使用当前定位的坐标反地理编码没有错误,从而确定调起百度SDK的APPId等信息的配置也是无误的,但是在此处失败,最后才发现将经纬度写反了,(CLLocationCoordinate2D){纬度、经度}方式
//实现Delegate处理回调结果
- (void)onGetSuggestionResult:(BMKSuggestionSearch*)searcher result:(BMKSuggestionResult*)result errorCode:(BMKSearchErrorCode)error{
if (error == BMK_SEARCH_NO_ERROR)
{
[allArr removeAllObjects];
for (int i = 0;i < result.keyList.count;i++)
{
NSValue *value = result.ptList[i];
[allArr addObject:value];
}
[table_addreList reloadData];
}
}
//百度检索
- (void)BMKSearch:(CLLocationCoordinate2D)pt
{
//初始化检索对象
_codeSearcher =[[BMKGeoCodeSearch alloc]init];
_codeSearcher.delegate = self;
//构造AMapReGeocodeSearchRequest对象
BMKReverseGeoCodeOption *reverseGeoCodeSearchOption = [[BMKReverseGeoCodeOption alloc]init];
reverseGeoCodeSearchOption.reverseGeoPoint = pt;
//发起逆地理编码
[_codeSearcher reverseGeoCode:reverseGeoCodeSearchOption];
}
//实现逆地理编码的回调函数
- (void) onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
{
if (error == BMK_SEARCH_NO_ERROR)
{
if (result.addressDetail.province != nil ||
![result.addressDetail.province isEqualToString:@""]) {
NSString *address = [NSString stringWithFormat:@"%@",result.address];
NSLog(@"address==%@",address);
//地址(省市、街道)
_addressDetail = result.addressDetail;
//!!!!!!!!切记此处经纬度坐标不要写反
NSValue *value = allArr[addressindex];
CGPoint b = value.CGPointValue;
}
}
}