iOS-Andriod百度地圖仿百度外賣-餓了麼-選擇我的地址-POI檢索/,ios-andriod-poi

來源:互聯網
上載者:User

iOS-Andriod百度地圖仿百度外賣-餓了麼-選擇我的地址-POI檢索/,ios-andriod-poi

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的朋友可以留郵箱.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.