您的位置:首页 > 移动开发 > IOS开发

iOS-Andriod百度地图仿百度外卖-饿了么-选择我的地址-POI检索/

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

title: iOS Andriod百度地图仿百度外卖 饿了么 选择我的地址 POI检索

date: 2015-09-19 21:06:26

tags:

百度外卖选择送货地址:






饿了么选择送货地址:





百度地图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的朋友可以留邮箱.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: