1. //
  2. // PoiViewController.m
  3. // baiDuDemo
  4. //
  5. // Created by City--Online on 15/6/4.
  6. // Copyright (c) 2015年 XQB. All rights reserved.
  7. //
  8.  
  9. #import "PoiViewController.h"
  10. #import "BMKTypes.h"
  11. #import "BMKPoiSearch.h"
  12. #import "BMKBusLineSearch.h"
  13. #import "BMKGeocodeSearch.h"
  14. @interface PoiViewController ()<BMKPoiSearchDelegate,BMKGeoCodeSearchDelegate,UITableViewDataSource,UITableViewDelegate>
  15. //周边、详情搜索
  16. @property(nonatomic,strong) BMKPoiSearch *searcher;
  17. //周边搜索条件
  18. @property(nonatomic,strong) BMKNearbySearchOption *nearbySearchOption;
  19. //详情搜索条件
  20. @property(nonatomic,strong) BMKPoiDetailSearchOption *detailSearchOption;
  21.  
  22. @property(nonatomic,strong) UITableView *tableView;
  23. //周边搜索列表数据
  24. @property(nonatomic,strong) NSMutableArray *poiInfoList;
  25.  
  26. //地理信息编码
  27. @property(nonatomic,strong) BMKGeoCodeSearch *geoCodeSearch;
  28.  
  29. @end
  30.  
  31. @implementation PoiViewController
  32.  
  33. - (void)viewDidLoad {
  34. [super viewDidLoad];
  35.  
  36. //初始化检索对象
  37. _searcher =[[BMKPoiSearch alloc]init];
  38. _searcher.delegate = self;
  39. //发起周边检索
  40. _nearbySearchOption = [[BMKNearbySearchOption alloc]init];
  41. // _nearbySearchOption.pageIndex = 1;
  42. // _nearbySearchOption.pageCapacity = 10;
  43. _nearbySearchOption.location=CLLocationCoordinate2DMake(22.5538, 114.0672);
  44. _nearbySearchOption.radius=;
  45. _nearbySearchOption.sortType=BMK_POI_SORT_BY_DISTANCE;
  46. _nearbySearchOption.keyword = @"小吃";
  47. BOOL flag = [_searcher poiSearchNearBy:_nearbySearchOption];
  48.  
  49. if(flag)
  50. {
  51. NSLog(@"周边检索发送成功");
  52. }
  53. else
  54. {
  55. NSLog(@"周边检索发送失败");
  56. }
  57.  
  58. // 地理信息编码
  59. _geoCodeSearch =[[BMKGeoCodeSearch alloc]init];
  60. _geoCodeSearch.delegate = self;
  61. BMKGeoCodeSearchOption *geoCodeSearchOption = [[BMKGeoCodeSearchOption alloc]init];
  62. geoCodeSearchOption.city= @"深圳市";
  63. geoCodeSearchOption.address = @"音乐厅";
  64. flag = [_geoCodeSearch geoCode:geoCodeSearchOption];
  65. if(flag)
  66. {
  67. NSLog(@"geo检索发送成功");
  68. }
  69. else
  70. {
  71. NSLog(@"geo检索发送失败");
  72. }
  73.  
  74. // 地理信息反编码
  75. CLLocationCoordinate2D pt = (CLLocationCoordinate2D){22.588393, 113.946523};
  76. BMKReverseGeoCodeOption *reverseGeoCodeSearchOption = [[
  77. BMKReverseGeoCodeOption alloc]init];
  78. reverseGeoCodeSearchOption.reverseGeoPoint = pt;
  79. flag = [_geoCodeSearch reverseGeoCode:reverseGeoCodeSearchOption];
  80. if(flag)
  81. {
  82. NSLog(@"反geo检索发送成功");
  83. }
  84. else
  85. {
  86. NSLog(@"反geo检索发送失败");
  87. }
  88.  
  89. _tableView =[[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
  90. [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
  91. _tableView.dataSource=self;
  92. _tableView.delegate=self;
  93. [self.view addSubview:_tableView];
  94.  
  95. }
  96.  
  97. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  98. {
  99.  
  100. return _poiInfoList.count;
  101.  
  102. }
  103. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  104. {
  105. UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
  106. BMKPoiInfo *poiInfo=[_poiInfoList objectAtIndex:indexPath.row];
  107. cell.textLabel.text=[NSString stringWithFormat:@"%@ %@",poiInfo.name,poiInfo.uid];
  108. return cell;
  109. }
  110. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  111. {
  112.  
  113. //发起详情搜索
  114. _detailSearchOption=[[BMKPoiDetailSearchOption alloc]init];
  115. BMKPoiInfo *poiInfo=[_poiInfoList objectAtIndex:indexPath.row];
  116. _detailSearchOption.poiUid=poiInfo.uid;
  117. BOOL flag = [_searcher poiDetailSearch:_detailSearchOption];
  118. if(flag)
  119. {
  120. NSLog(@"详情检索发起成功");
  121. //详情检索发起成功
  122. }
  123. else
  124. {
  125. NSLog(@"详情检索发送失败");
  126. //详情检索发送失败
  127. }
  128.  
  129. }
  130. //周边搜索
  131. - (void)onGetPoiResult:(BMKPoiSearch*)searcher result:(BMKPoiResult*)poiResult errorCode:(BMKSearchErrorCode)errorCode
  132. {
  133. if (errorCode == BMK_SEARCH_NO_ERROR) {
  134. _poiInfoList=[poiResult.poiInfoList mutableCopy];
  135. [_tableView reloadData];
  136. NSLog(@"%d %d %d %d",poiResult.totalPoiNum,poiResult.currPoiNum,poiResult.pageNum,poiResult.pageIndex);
  137. for (BMKPoiInfo *poiInfo in poiResult.poiInfoList) {
  138. NSLog(@"name:%@ UId:%@",poiInfo.name,poiInfo.uid);
  139.  
  140. }
  141. for (BMKCityListInfo *CityListInfo in poiResult.cityList) {
  142. NSLog(@"%@",CityListInfo.city);
  143. }
  144.  
  145. }
  146. else if (errorCode == BMK_SEARCH_AMBIGUOUS_KEYWORD){
  147. //当在设置城市未找到结果,但在其他城市找到结果时,回调建议检索城市列表
  148. // result.cityList;
  149. NSLog(@"起始点有歧义");
  150. } else {
  151. NSLog(@"抱歉,未找到结果");
  152. }
  153. }
  154. //详情搜索
  155. - (void)onGetPoiDetailResult:(BMKPoiSearch*)searcher result:(BMKPoiDetailResult*)poiDetailResult errorCode:(BMKSearchErrorCode)errorCode
  156. {
  157. if (errorCode == BMK_SEARCH_NO_ERROR) {
  158. NSLog(@"%@ %@ %@ %@",poiDetailResult.name,poiDetailResult.address,poiDetailResult.phone,poiDetailResult.shopHours);
  159. NSString *message=[NSString stringWithFormat:@"店名:%@ \n地址:%@\n 电话:%@\n 营业时间:%@\n经纬度:%lf %lf",poiDetailResult.name,poiDetailResult.address,poiDetailResult.phone,poiDetailResult.shopHours,poiDetailResult.pt.latitude,poiDetailResult.pt.longitude];
  160. UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"搜索详情" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
  161. [alertView show];
  162.  
  163. }
  164. else if (errorCode == BMK_SEARCH_AMBIGUOUS_KEYWORD){
  165. //当在设置城市未找到结果,但在其他城市找到结果时,回调建议检索城市列表
  166. // result.cityList;
  167. NSLog(@"起始点有歧义");
  168. } else {
  169. NSLog(@"抱歉,未找到结果");
  170. }
  171.  
  172. }
  173. - (void)onGetGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
  174. {
  175. if (error == BMK_SEARCH_NO_ERROR) {
  176. NSLog(@"%lf %lf %@",result.location.latitude,result.location.longitude,result.address);
  177. }
  178. else {
  179. NSLog(@"抱歉,未找到结果");
  180. }
  181.  
  182. }
  183. - (void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error
  184. {
  185. if (error == BMK_SEARCH_NO_ERROR) {
  186. NSLog(@"%@",result.address);
  187. for (BMKPoiInfo *poiInfo in result.poiList) {
  188. NSLog(@"%@ %@",poiInfo.name,poiInfo.address);
  189. }
  190.  
  191. }
  192. else {
  193. NSLog(@"抱歉,未找到结果");
  194. }
  195.  
  196. }
  197.  
  198. - (void)didReceiveMemoryWarning {
  199. [super didReceiveMemoryWarning];
  200. // Dispose of any_ resources that can be recreated.
  201. }
  202.  
  203. @end

百度地图之POI的更多相关文章

  1. Android学习笔记之使用百度地图实现Poi搜索

    PS:装个系统装了一天.心力憔悴.感觉不会再爱了. 学习内容: 1.使用百度Map实现Poi搜索. 2.短串分享 3.在线建议查询   百度地图的研究也算是过半了.能够实现定位,实现相关信息的搜索,实 ...

  2. 教你如何拔取百度地图POI兴趣点

    教你如何拔取百度地图POI兴趣点   通过聚合数据提供的接口,获取百度地图的POI兴趣点,并存储至数据库中. 实现: 1.聚合数据百度POI接口说明 调用聚合数据,首先得注册聚合.聚合数据提供的百度地 ...

  3. 百度地图开发之POI数据检索

    前面学习百度地图的一些基本的用法,这次我们一起来看一看百度地图的检索功能吧 poi检索api的基本用法 百度地图的POI类中共有如下几个方法 PoiBoundSearchOption POI范围内检索 ...

  4. 获取百度地图POI数据二(准备搜索关键词)

    上篇讲到  想要获取尽可能多的POI数据 需要准备尽可能多的搜索关键字   那么这些关键字如何得来呢?   本人使用的方法是通过一些网站来获取这些关键词   http://poi.mapbar.com ...

  5. 百度地图POI数据爬取,突破百度地图API爬取数目“400条“的限制11。

    1.POI爬取方法说明 1.1AK申请 登录百度账号,在百度地图开发者平台的API控制台申请一个服务端的ak,主要用到的是Place API.检校方式可设置成IP白名单,IP直接设置成了0.0.0.0 ...

  6. iOS第三方地图-百度地图常用功能使用(POI搜索,地理正反编码,定位,添加标注)

    百度地图官网: http://developer.baidu.com/map/index.php?title=iossdk 百度地图集成 1.引入相关包

  7. (转载) 百度地图工具类封装(包括定位,附近、城市、范围poi检索,反地理编码)

    目录视图 摘要视图 订阅 赠书 | 异步2周年,技术图书免费选      程序员8月书讯      项目管理+代码托管+文档协作,开发更流畅 百度地图工具类封装(包括定位,附近.城市.范围poi检索, ...

  8. IOS_OC_百度地图与社交分享

    前奏. 知识点介绍 一. 导航和画线 地图画线 (理解) 二. 百度地图 集成百度地图 (掌握) POI检索 (掌握) 三. 社交分享 系统自带分享 (了解) 友盟分享 (掌握) SSO授权 (理解) ...

  9. 百度地图Key的设置方法

    一.为什么要设置百度Key 万能地图下载器提供了百度POI的下载功能,但由于本软件用户群极大,会导致一天之内访问量超出300万次以上而无法继续下载. 因此,当POI下载不成功能,用户可以自己申请百度地 ...

随机推荐

  1. MySQL的20条基本优化 加参考资料

    mysql的性能优化包罗甚广:索引优化,查询优化,查询缓存,服务器设置优化,操作系统和硬件优化,应用层面优化(web服务器,缓存)等等.这里的记录的优化技巧更适用于开发人员,都是从网络上收集和自己整理 ...

  2. 基于Vivado HLS在zedboard中的Sobel滤波算法实现

     基于Vivado HLS在zedboard中的Sobel滤波算法实现 平台:zedboard  + Webcam 工具:g++4.6  + VIVADO HLS  + XILINX EDK + ...

  3. eclipse指定启动的jdk

    原文:http://my.oschina.net/noday/blog/203987 到eclipse目录,打开eclipse.ini文件,在指定位置加入你的jdk相关文件(如下面示例配置中-vm配置 ...

  4. ngx_http_upstream_module模块学习笔记

    ngx_http_upstream_module用于将多个服务器定义成服务器组,而由proxy_pass,fastcgi_pass等指令引用 (1)upstream name  {...} 定义一个后 ...

  5. 室内净化ThinkPHP复习

    "$_GET[id]"这个是和$_GET['id']一样的 foreach的是 name 和 item if(!empty($_GET['id'])){ $where.= &quo ...

  6. (原创)Windows8下安装配置WAMP

    Windows8下安装配置WAMP        2013/12/28 最近这段时间一直在研究linuxshell编程,虽然还是初级水平,但比之前有了不小的进度,但是shell的命令很多,很难在短时间 ...

  7. 一,U盘安装 CentOS 6.5 minimal

    U盘安装盘: CentOS-6.5的版本有四个,分别是: 1.CentOS-6.5-i386-netinstall.iso 通过网络安装的,需要联网 2.CentOS-6.5-i386-minimal ...

  8. 第十八章 数据访问(In .net4.5) 之 I/O操作

    1. 概述 本章内容包括 文件操作.流操作.读写网络数据 以及 异步I/O操作. 2. 主要内容 2.1 文件操作 ① 使用 Drive 和 DriveInfo 访问磁盘信息. DriveInfo[] ...

  9. hihoCoder-1000-A+B

    题目描述:传统的A+B题 使用语言:C 代码: #include <stdio.h> int main(void){ int a,b; while((scanf("%d %d&q ...

  10. 菜鸟学习Spring——60s学会Spring与Hibernate的集成

    一.概述. Spring与Hibernate的集成在企业应用中是很常用的做法通过Spring和Hibernate的结合能提高我们代码的灵活性和开发效率,下面我就一步一步的给大家讲述Spring如何和H ...