Suggest
The main function of the search suggestion is to display a result similar to the keyword based on the input keyword.
1. Import header files
#import <NavinfoKit/NavinfoKit.h>
2. Configure APIKEY
Refer to Project Configuration Instructions.
3. Define NavinfoPOISearch
Define the main search object NavinfoPOISearch and inherit the search protocol <NavinfoQueryDelegate>.
4. Constructing NavinfoPOISearch
Construct an event search object NavinfoPOISearch and set the proxy.
self.search = [[NavinfoPOISearch alloc] init]; self.search.delegate = self;
5. Setting suggest search query parameters
The request parameter class of the charging pile search query along the way is NavinfoPOIQuery, and the keyword (keyword), city (city), and category (search type) are mandatory parameters.
Keyword search category is SERVICE_API_SUGGEST.
Self.query = [[NavinfoPOIQuery alloc] initWithKeyword:@"HOME INN" city:@"BEIJING" lonlats:nil category:SERVICE_API_SUGGEST];
6. Initiate keyword search query parameters
Initiate a keyword search query by calling the search method of NavinfoPOISearch.
[self.search search:self.query];
7. Processing data in callbacks
When the query is successful, it will go to the POISearch:result:error callback function, through the callback function, you can get the result of the query keyword search.
- (void)POISearch:(NavinfoPOISearch *)poiSearch result:(NavinfoPOISearchResult *)result error:(NSError *)error
Description:
1) Get the total number of results retrieved by result.
2) Get the identifier of the filtering sorting configuration information by result.
3) Get a list of province distribution results by result. provinces. See NavinfoProvince for details.
4) Get a list of POI messages via result pois. Refer to NavinfoPOI for details.
5) Obtain administrative area switching information through result. For more information, please refer to NavinfoDistrict
8. Processing failed queries
When the retrieval fails, Error returns, and the reason for the failure is obtained by the callback function.