百度地图SDK反地理编码错误

在使用百度地图时,严格按照百度文档做的,通过搜索获取了检索的地址列表之后,取得了当前选择地址行的坐标(经纬度),但是通过输入经纬度去获得具体地址信息时,返回的地址信息是空,在确定使用当前定位的坐标反地理编码没有错误,从而确定调起百度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;
        }
    }
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值