Location:

Administrative Area

1. Import header files

                    #import <NavinfoKit/NavinfoKit.h>
                

2. Configure APIKEY

Refer to Project Configuration Instructions.

3. Define NavinfoDistrictSearch

Define the traffic search object NavinfoDistrictSearch and inherit the search protocol <NavinfoDistrictDelegate>.

4. Construct NavinfoDistrictSearch

Construct an event search object NavinfoDistrictSearch and set the proxy.

                    _distSearch = [NavinfoDistrictSearch new];
                    _distSearch.delegate = self;
                

5. Set administrative area search query parameters

The request parameter class of the road fuzzy search query is NavinfoDistrictQuery, keyword (keyword) is a non-required parameter, search keyword support: administrative area name, code, adcode, subDistrictCount (child level administrative area). Set to display the lower administrative level; hasExtensionInfo (administrative area boundary) controls whether the administrative boundary coordinates are returned. Please refer to the API documentation for other parameters.

                    NavinfoDistrictQuery *query = [NavinfoDistrictQuery new];
                    Query.keyword = @"LIAONING";
                    query.subDistrictCount = 1;
                    query.hasExtensionInfo = NO;
                

6. Initiate search query parameters

Initiate a search request by calling the districtSearchWithQuery method of NavinfoDistrictQuery.

                    [_distSearch districtSearchWithQuery:query];
                

7. Processing data in callbacks

Proxy method when the query is successful.

                    - (void)onDistrictSearch:(NavinfoDistrictSearch *)search result:(NavinfoDistrictResult * _Nullable)result error:(NSError * _Nullable)error;
                

where NavinfoDistrictResult returns, NSError is nil, and the query result can be obtained at this time.

Description:

Get a collection of NavinfoBaseDistrict types through districts.

                    - (void)onDistrictSearch:(NavinfoDistrictSearch *)search result:(NavinfoDistrictResult *)result error:(NSError *)error {
                        NSLog(@"----> onDistrictSearch");
                        if (result.districts) {
                            NavinfoBaseDistrict *dist = result.districts[0];
                            NSString *adcode = dist.adcode;
                            NSString *cityCode = dist.cityCode;
                            NSString *name = dist.name;
                            NavinfoLonlat *lonlat = dist.center;
                            NSString *center = [lonlat lonlatString];
                            NSString *lonlats = dist.lonlats;
                            NSString *level = dist.level;
                            NSArray *dists = dist.districts;
                            NSLog(@"----> result.adcode=%@, result.cityCode=%@, result.name=%@, result.center= %@, result.lonlats=%@, result.level=%@",adcode,cityCode,name,center,lonlats,level);
                            for (NSInteger i = 0; i < [dists count]; i++) {
                                NSLog(@"----> subdist.adcode=%@, subdist.cityCode=%@, subdist.name=%@, subdist.lonlats=%@, subdist.level=%@",dist.districts[i].adcode,dist.districts[i].cityCode,dist.districts[i].name,dist.districts[i].lonlats,dist.districts[i].level);
                            }
                        }
                    }
                

8. Processing a failed query When the retrieval fails, Error returns, and the reason for the failure is obtained by the callback function.

TOP