高德地图POI搜索,附近地图搜索,类似附近的人搜索


效果图:




首先导入道德地图的SDK,导入步骤不在这里介绍

2:包含头文件:

  1. #import <AMapSearchKit/AMapSearchAPI.h>  
3:代码

[javascript] view plain copy
在CODE上查看代码片 派生到我的代码片
  1. @property(nonatomic,strong)AMapSearchAPI *mapSearch;  
  2. @property(nonatomic,strong)AMapPlaceSearchRequest *poiRequest;  



  1. -(void)searchAroundLocal:(AMapGeoPoint *)geoPoint  
  2. {  
  3.   
  4.     if ( !self.mapSearch) {  
  5.         self.mapSearch=[[AMapSearchAPI alloc] initWithSearchKey:(NSString *)APIKey Delegate:self];  
  6.     }  
  7.       
  8.     self.poiRequest = [[AMapPlaceSearchRequest alloc] init];  
  9.       
  10.       
  11.     AMapGeoPoint *searchPoint =[AMapGeoPoint locationWithLatitude:  
  12.                                 22.540000  
  13.                                                         longitude:113.900000];  
  14.       
  15.     self.poiRequest.searchType = AMapSearchType_PlaceAround;//搜索的类型为周边搜索  
  16. //    self.poiRequest.types =AMapRequireGroupbuy;                 //搜索的内容  
  17.     self.poiRequest.offset = 120;                //每页搜索的信息个数  
  18.     self.poiRequest.location = searchPoint;      //搜索的中心点  
  19.     self.poiRequest.keywords=searchKeyString;  
  20.     self.poiRequest.radius = 5000;               //搜索半径  
  21.     self.poiRequest.sortrule = 0;                //结果以远近排序  
  22.     //发起POI搜索  
  23.     [self.mapSearch AMapPlaceSearch:self.poiRequest];//发起请求搜索  
  24. }  
  25. #pragma mark - AMapSearchDelegate  
  26. /* POI 搜索回调. */  
  27. - (void)onPlaceSearchDone:(AMapPlaceSearchRequest *)request response:(AMapPlaceSearchResponse *)response  
  28. {  
  29.     NSLog(@"inset=%@",TABLEHEAD);  
  30.     for (AMapPOI *p in response.pois) {  
  31.         if (p) {  
  32.               
  33.             [locArr addObject:p];  
  34.               
  35.         }  
  36.           
  37.     }  
  38.     [locArr insertObject:TABLEHEAD atIndex:0];  
  39.     [self.view endEditing:YES];  
  40.     [self.tableView reloadData];  
  41. }  
  42.   
  43. - (void)searchRequest:(id)request didFailWithError:(NSError *)error  
  44. {  
  45.     NSLog(@"====出错信息:%@",error);  
  46. }  
  47. - (void)search:(id)searchRequest error:(NSString *)errInfo __attribute__ ((deprecated("use -search:didFailWithError instead.")))  
  48. {  
  49.   NSLog(@"====出错信息:%@",errInfo);  
  50. }  

其中

self.poiRequest.keywords=searchKeyString;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值