在使用百度地图时,严格按照百度文档做的,通过搜索获取了检索的地址列表之后,取得了当前选择地址行的坐标(经纬度),但是通过输入经纬度去获得具体地址信息时,返回的地址信息是空,在确定使用当前定位的坐标反地理编码没有错误,从而确定调起百度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 < unt;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];verseGeoPoint = 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;}}
}
本文发布于:2024-03-05 17:27:41,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/1709701012124082.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |