anytime_is_sunlight 2015-01-05 13:58 采纳率: 100%
浏览 1751

高德地图的搜索功能的实现

我这里项目的需要是,使用高德地图,
要把地图上距离我当前位置这个大头针显示的位置的2公里之内的住宿,酒店,餐饮的信息,
全部检索到并显示在地图上,
我这里在项目里面要显示结果的地方添加的代码如下,

//初始化检索对象
_searchMapView = [[AMapSearchAPI alloc] initWithSearchKey:@"549f6a2bfd98c54aaf000c6f" Delegate:self];
if ([kCurentLanguage isEqualToString:@"en"]) {
_searchMapView.language = AMapSearchLanguage_en;
}
else if ([kCurentLanguage isEqualToString:@"zh-Hans"]) {
_searchMapView.language = AMapSearchLanguage_zh_CN;
}
//构造AMapPlaceSearchRequest对象,配置关键字搜索参数
AMapPlaceSearchRequest *poiRequest = [[AMapPlaceSearchRequest alloc] init];
poiRequest.searchType = AMapSearchType_PlaceKeyword;
poiRequest.keywords = @"俏江南";
poiRequest.city = @[@"beijing"];
poiRequest.requireExtension = YES;

//发起POI搜索
[_searchMapView AMapPlaceSearch: poiRequest];

相应的搜索的代理的回调代码如下,可是怎么就是没有搜索结果显示呢?

//实现POI搜索对应的回调函数

  • (void)onPlaceSearchDone:(AMapPlaceSearchRequest *)request response:(AMapPlaceSearchResponse *)response
    {
    if(response.pois.count == 0)
    {
    return;
    }

    //通过AMapPlaceSearchResponse对象处理搜索结果
    NSString *strCount = [NSString stringWithFormat:@"count: %ld",response.count];
    NSString *strSuggestion = [NSString stringWithFormat:@"Suggestion: %@", response.suggestion];
    NSString *strPoi = @"";
    for (AMapPOI *p in response.pois) {
    strPoi = [NSString stringWithFormat:@"%@\nPOI: %@", strPoi, p.description];
    }
    NSString *result = [NSString stringWithFormat:@"%@ \n %@ \n %@", strCount, strSuggestion, strPoi];
    NSLog(@"Place: %@", result);
    }

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 关于#python#的问题:自动化测试