iOS Andriod百度地圖仿百度外賣 餓了麼 選擇我的地址 POI檢索

http://zanderzhang.gitcafe.io/2015/09/19/iOS-Andriod百度地圖仿百度外賣-餓了麼-選擇我的地址-POI檢索/

title: iOS Andriod百度地圖仿百度外賣 餓了麼 選擇我的地址 POI檢索 date: 2015-09-19 21:06:26

tags:

百度外賣選擇送貨地址: 餓了麼選擇送貨地址:

百度地圖api官網

第一個圖,就是放一個UIImageViewMapView的中間,然後我們拖動的時候下面地圖在跑. 

-(void)addMiddleImage{

    UIImageView *imaV=[UIImageView new];

    imaV.center=_mapView.center;

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

    imaV.p_w_picpath=[UIImage p_w_picpathNamed:@"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的朋友可以留郵箱.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章