Bus Routing

1. Import header files

  1. #import <NavinfoKit/NavinfoKit.h>

2. Configure APIKEY

Refer to Project Configuration Instructions.

3. Define NavinfoRouteSearch

Define the master road object NavinfoRouteSearch and inherit the search protocol <NavinfoRouteQueryDelegate>.

4. Construct NavinfoRouteSearch

Construct the main search object NavinfoRouteSearch and set the proxy.

  1. NavinfoRouteSearch * routeSearch = [[NavinfoRouteSearch alloc] init]; routeSearch.delegate = self;

5. Set the parameters for initiating bus calculations

where orig (starting point coordinates) vias (path point coordinate set can be empty) dest (end point coordinates) query (calculation type).

  1. - (id)initBusQueryWith:(NavinfoLonlat * _Nonnull)orig dest:(NavinfoLonlat * _Nonnull)dest city:(NSString *)cityName;

6. Initiating a road

Initiate a calculation query by calling the startSearch method of NavinfoSearchRoute.

  1. [search startSearchWith:query];

7. Processing data in callbacks

When the query is successful, it will enter the callback function, and the callback function can get the result of the calculation.

Description:

Get a driving and transfer plan set via response.routes.

  1. - (void)onRouteSearch:(NavinfoRouteSearch * _Nonnull)routeSearch
    result:(NavinfoRouteResult * _Nullable)result
    error:(NSError * _Nullable)error {
    NSLog(@"----> onRouteSearch");
    }

8. Processing failed queries

When the retrieval fails, Error returns, and the reason for the failure is obtained by the callback function.

  1. - (void)onRouteSearch:(NavinfoRouteSearch * _Nonnull)routeSearch
    result:(NavinfoRouteResult * _Nullable)result
    error:(NSError * _Nullable)error {
    NSLog(@"----> onRouteSearch");
    }
TOP