Just do Baidu map poi Search, take to share, based on Baidu Map 2.3.0SDK development, to be honest, this new version of POI really does not work
First of all, the contents of the file, define the Poi object, of course, you can also write to the implementation of the file inside
#import <UIKit/UIKit.h> #import "BMapKit.h" @interface Nearbyplaceviewcontroller:viewcontrollerbase < bmkpoisearchdelegate>{Bmkpoisearch *_poisearch; POI Search} @end
#import "NearByPlaceViewController.h" #import "UserLocationManager.h" #import "IToast.h" @ interface nearbyplaceviewcontroller () { nsstring *_cityname; // Search city name NSString *_keyWord; // search keywords int currentPage; // current Page} @property (retain,nonatomic) NSMutableArray *poiResultArray; //poi Result information collection @end@implementation nearbyplaceviewcontroller- (ID) Initwithnibname: (nsstring *) Nibnameornil bundle: (nsbundle *) nibbundleornil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // custom initialization } &nBsp; return self;} - (void) viewdidload{ [super viewdidload]; self.view.backgroundcolor = [uicolor whitecolor]; [self Setarrayspace]; [self initpoisearch];} #pragma mark --Logarithmic group Open Space-(void) setarrayspace{ nsmutablearray *mutarr1 = [[nsmutablearray alloc]init]; _poiresultarray = mutarr1; nsmutablearray *mutarr2 = [[nsmutablearray alloc ]INIT];&NBSP;&NBSP;&NBSP;&NBSP;_SEARCHHISTORYARRAY&NBSP;=&NBSP;MUTARR2;} #pragma mark --Initialize the POI class-(void) initpoisearch{ _poisearch = [[ bmkpoisearch alloc]init]; _poisearch.delegate = self; currentpage = 0; //near Cloud search, other search partiesSee details api bmknearbysearchoption *nearbysearchoption = [[ bmknearbysearchoption alloc]init]; nearbysearchoption.pageindex = currentpage; //the first few pages of nearbysearchoption.pagecapacity = 10; // Up to several pages nearbysearchoption.keyword = @ "facilities"; //search keywords nearbysearchoption.location = [userlocationmanager sharedinstance]. Clloction.coordinate; // poi Search Points nearBySearchOption.radius = 1000; //Search Scope m bool flag = [_poisearch poisearchnearby: NEARBYSEARCHOPTION];&NBSP;&NBSP;&NBSP;&NBSP;IF (flag) { nslog (@ "in-City search sent successfully"); } else { nslog (@ "City&NBSP;&NBSP;&NBSP;&NBSP}} #pragma mark --bmkpoisearchdelegate/** * return poi search Results *@ param searcher Search Object * @param poiResult search results list * @param errorCode error number, @ see bmksearcherrorcode */- (void) Ongetpoiresult: (bmkpoisearch*) Searcher result: ( bmkpoiresult*) Poiresult errorcode: (Bmksearcherrorcode) errorcode{ if ( Errorcode == bmk_search_no_error) { for (int i = 0; i < poiresult.poiinfolist.count; i++) { BMKPoiInfo* poi = [poiResult.poiInfoList objectAtIndex:i]; [_poiResultArray addObject:poi]; } } else if (Errorcode == bmk_search_result_not_found) { [self settoast:itoastgravitybottom withtext:@ "Sorry, I can't find the information in the area near you!"]; }} #pragma mark - toast-(void) Settoast: (itoastgravity) gravity withtext: (nsstring*) text{ iToast *toast = [iToast maketext:text]; [toast setgravity:gravity]; [toast Setduration:5]; [toast setfontsize:15]; [toast show];} - (void) didreceivememorywarning{ [super didreceivememorywarning]; // dispose of any resources that can be recreated.} @end
Everyone has what do not understand can give me message, will return, exchange with each other, follow-up I will do Baidu map encountered detailed records, we can exchange a bit more!