http://zanderzhang.gitcafe.io/2015/09/19/iOS-Andriod百度地图仿百度外卖-饿了么-选择我的地址-POI检索/

百度外卖选择送货地址: 饿了么选择送货地址:

百度地图api官网

第一个图,就是放一个UIImageView在MapView的中间,然后我们拖动的时候下面地图在跑.

-(void)addMiddleImage{

UIImageView *imaV=[UIImageView new];

imaV.center=_mapView.center;

imaV.bounds=CGRectMake(0, 0, 24, 36);

imaV.image=[UIImage imageNamed:@"poi_icon"];

[self.view addSubview:imaV];

}

取屏幕中心点,也就是UIImageView的坐标:

geo.reverseGeoPoint=mapStatus.targetGeoPt;

geo是BMKReverseGeoCodeOption *geo; 移动完成会调用:

-(void)mapStatusDidChanged:(BMKMapView *)mapView{

BMKMapStatus *mapStatus=[mapView getMapStatus];

geo.reverseGeoPoint=mapStatus.targetGeoPt;

[_geoSearcher reverseGeoCode:geo];

NSLog(@"mapStatusDidChanged");

}

回调函数获得反编译结果和周边result.poiList:

-(void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeResult *)result errorCode:(BMKSearchErrorCode)error{

[geoArr removeAllObjects];

[geoArr addObjectsFromArray:result.poiList];

if (result.poiList.count) {

BMKPoiInfo *info=result.poiList[0];

_city=info.city;

}

[_bottomTable reloadData];

}

第二个图,我开始使用在线建议查询,后面发现这个POI搜索更好用点,它有三种,我使用的是POI城市内搜索:

开始检索:

bMKPoiSearch =[[BMKPoiSearch alloc]init];

bMKPoiSearch.delegate = self;

BMKCitySearchOption *option=[BMKCitySearchOption new];

//    城市内搜索

option.city =city;

option.keyword  = searchText;

[bMKPoiSearch poiSearchInCity:option];

回调返回:

-(void)onGetPoiResult:(BMKPoiSearch )searcher result:(BMKPoiResult )poiResult errorCode:(BMKSearchErrorCode)errorCode{[suggestionSearchArr removeAllObjects];

[suggestionSearchArr addObjectsFromArray:poiResult.poiInfoList];

[_suggestionTable reloadData];}`

在poiResult里面有poiInfoList,成员是BMKPoiInfo,跟第一个图一样.

Andriod和这差不多,函数有所区别.有需要demo的朋友可以留邮箱.

最新文章

  1. robotframework----模板的使用
  2. PHP的学习--图解PHP引用
  3. zookeeper命令行(zkCli.sh&zkServer.sh)使用及四字命令
  4. mongodb 几个要注意的问题
  5. arcgis中使用excel中x,y坐标创建点问题
  6. iOS-UIScrollView的delaysContentTouches与canCencelContentTouches属性
  7. 基于visual Studio2013解决C语言竞赛题之0803报数
  8. java抽象类和接口的区别(转载)
  9. [oracle]Oracle角色管理
  10. Handlebars 新手使用
  11. HBuilderx中编译sass文件
  12. php 浏览记录功能
  13. 关于POD和非POD类型中,list initialization和constructor initialization(未解决)
  14. TiDB 深度实践之旅--真实“踩坑”经历
  15. js 提示框的实现---组件开发之(二)
  16. 26、redis中默认有多少个哈希槽?
  17. C语言 · 企业奖金发放
  18. Linux服务器---本地yum
  19. android 管理fragment
  20. centos7 取消自动锁屏

热门文章

  1. Codeforces Round #311 (Div. 2)B. Pasha and Tea 水题
  2. 【JavsScript】JavaScript MVC 框架技术选型
  3. 安装linux系统并配置那点事
  4. Fork/Join框架之双端队列
  5. 摘录知乎上关于android开发的话题精华
  6. innobackupex 恢复实验
  7. mysqldump 安全 --skip-add-drop-table
  8. CENTOS YUM软件源
  9. 对shell中的与(&&)和或(||)的理解
  10. python编码encode和decode