我这里项目的需要是,使用高德地图,
要把地图上距离我当前位置这个大头针显示的位置的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);
}