Poi search in the previous article can search for poi in a specific range around the specified location. If you want to search for "Beijing" in Shanghai People's Square, poi returns a list of Beijing Roast Duck shops nearby. For this reason, sometimes we need to identify whether the user-entered search content is an address. here we need to use the address search described in this article.
1. Search first
Bmksearch * search = [[bmksearch alloc] init]; // create a search object search. delegate = self; // when the proxy is set to itself, the function [search geocode: "Beijing" withcity: @ ""] in the next step is automatically called back after the search. // search for Beijing // [Search release]; // Note: release is not supported. Otherwise, it cannot be searched. Define search as a member variable.
2. Process search results
- (void)onGetAddrResult:(BMKAddrInfo*)result errorCode:(int)error{ if (error == BMKErrorOk) { BMKPointAnnotation* item = [[BMKPointAnnotation alloc]init]; item.coordinate = result.strAddr; item.title = result.geoPt; [mapView addAnnotation:item]; [item release]; }}
The above callback will automatically display the searched poi on the map through annotation.
IOS development based on Baidu map (1) -- current user location
IOS development based on Baidu map (2) -- getting poi
IOS development based on Baidu map (3) -- address search
IOS development based on Baidu map (4) -- path search
IOS development based on Baidu map (5)-Summary of core issues
IOS development based on Baidu map (6) -- Google coordinates to hundreds of coordinates
IOS development based on Baidu map (7) -- convert Baidu coordinates to Google coordinates