Location:

Traffic Event Broadcast

Road Event Broadcast

1. Import header files

                    #import <NavinfoKit/NavinfoKit.h> 
                

2. Configure APIKEY

Refer to Project Configuration Instructions.

3. Define NavinfoTrafficIncidentSearch

Define the traffic event search object NavinfoTrafficIncidentSearch and inherit the search protocol <NavinfoTrafficSearchDelegate >.

4. Construct NavinfoTrafficIncidentSearch

Construct an event search object NavinfoTrafficIncidentSearch and set the proxy.

                    _incidentSearch = [[NavinfoTrafficIncidentSearch alloc] init];
                    _incidentSearch.delegate = self;
                

5. Setting road event search query parameters

The request parameter class of the road event search query is NavinfoTrafficRoadQuery, and roadName (city name) and cityName (city name) are mandatory parameters.
Please refer to the API documentation for other non-essential parameters.

                    NavinfoTrafficRoadQuery *query = [NavinfoTrafficRoadQuery new];
                    query.roadName = @"GuangXian Road";
                    query.cityName = @"Dalian";
                

6. Initiate search query parameters

Initiate a road event search query by calling the roadIncidentSearch method of NavinfoTrafficIncidentSearch.

                    [_incidentSearch roadIncidentSearch:query];
                

7. Processing data in callbacks

Proxy method when the query is successful.

                    - (void)onTrafficIncidentRoadSearch:(NavinfoTrafficIncidentSearch * _Nonnull)incidentSearch
                    result:(NavinfoTrafficIncidentResult * _Nullable)result
                    error:(NSError * _Nullable)error;
                

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

Description:

1) Get a road event search instance via incidentSearch.

2) Get event ID information via eventId.

3) Get event details via eventInfo.

4) Get the event location via lonlat.

5) Get the event path name via roadName.

6) Get the event road direction via roadDirection.

                    - (void)onTrafficIncidentRoadSearch:(NavinfoTrafficIncidentSearch *)incidentSearch result:(NavinfoTrafficIncidentResult *)result 
                        error:(NSError *)error {
                        NSLog(@"----> onTrafficIncidentRoadSearch");
                        for (NSInteger index = 0; index < result.totalCount; index++) {
                            NavinfoTIncidentData *data = result.contents[index];
                            NSString *lonlatStr = [NavinfoLonlat toSringWithLonlats:@[data.lonlat]];
                            NSLog(@"\nID=%@, \nInfo=%@, \nlonlat=%@, \nroadName=%@, \nroadDir=%@, \nreli=%@, \nsTime=%@, \neTime=%@, \nuTime=%@, \ntype=%ld",
                                data.eventId,
                                data.eventInfo,
                                lonlatStr,
                                data.roadName,
                                data.roadDirection,
                                data.reliability,
                                data.startTime,
                                data.expectExpireTime,
                                data.updataTime,
                                data.eventType);
                        }
                    }
                

8. Processing failed queries

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

Front Event Broadcast

1. Import header files

                    #import <NavinfoKit/NavinfoKit.h>
                

2. Configure APIKEY

Refer to Project Configuration Instructions.

3. Define NavinfoTrafficIncidentSearch

Define the traffic event search object NavinfoTrafficIncidentSearch and inherit the search protocol <NavinfoTrafficSearchDelegate >.

4. Construct NavinfoTrafficIncidentSearch

Construct an event search object NavinfoTrafficIncidentSearch and set the proxy.

                    _incidentSearch = [[NavinfoTrafficIncidentSearch alloc] init];
                    _incidentSearch.delegate = self;
                    

5. Set the front event search query parameters

The request parameter class of the front event search query is NavinfoTrafficFrontQuery, and the lonlats (latitude and longitude string) is a mandatory parameter. For other non-essential parameters, please refer to the API documentation.

                    NavinfoTrafficFrontQuery *query = [NavinfoTrafficFrontQuery new];
                    query.lonlats = @[[[NavinfoLonlat alloc] initWith:11681387 latitude:3985554 gbType:NavinfoGbTypeG02],
                    [[NavinfoLonlat alloc] initWith:11681471 latitude:3985556 gbType:NavinfoGbTypeG02],
                    [[NavinfoLonlat alloc] initWith:11681475 latitude:3985554 gbType:NavinfoGbTypeG02],
                    [[NavinfoLonlat alloc] initWith:16814820 latitude:3985553 gbType:NavinfoGbTypeG02],
                    [[NavinfoLonlat alloc] initWith:11681484 latitude:3985550 gbType:NavinfoGbTypeG02],
                    [[NavinfoLonlat alloc] initWith:11681486 latitude:3985512 gbType:NavinfoGbTypeG02]];
                    query.direction = 270;
                

6. Initiate search query parameters

Initiate a forward event search query by calling the frontIncidentSearch method of NavinfoTrafficIncidentSearch.

                    [_incidentSearch frontIncidentSearch:query];
                

7. Processing data in callbacks

Proxy method when the query is successful.

                    - (void)onTrafficIncidentFrontSearch:(NavinfoTrafficIncidentSearch * _Nonnull)incidentSearch
                    result:(NavinfoTrafficIncidentResult * _Nullable)result
                    error:(NSError * _Nullable)error;
                

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

Description:

For the parameter information, please refer to [Road Event Voice Broadcast].

                    - (void)onTrafficIncidentFrontSearch:(NavinfoTrafficIncidentSearch *)incidentSearch result:(NavinfoTrafficIncidentResult *)result 
                    error:(NSError *)error {
                    NSLog(@"----> onTrafficIncidentFrontSearch");
                    for (NSInteger index = 0; index < result.totalCount; index++) {
                        NavinfoTIncidentData *data = result.contents[index];
                        NSString *lonlatStr = [NavinfoLonlat toSringWithLonlats:@[data.lonlat]];
                        NSLog(@"\nID=%@, \nInfo=%@, \nlonlat=%@, \nroadName=%@, \nroadDir=%@, \nreli=%@, \nsTime=%@, \neTime=%@, \nuTime=%@, \ntype=%ld",
                                data.eventId,
                                data.eventInfo,
                                lonlatStr,
                                data.roadName,
                                data.roadDirection,
                                data.reliability,
                                data.startTime,
                                data.expectExpireTime,
                                data.updataTime,
                                data.eventType);
                        }
                    }
                

8. Processing failed queries

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

Nearby Event Broadcast

1. Import header files

                    #import <NavinfoKit/NavinfoKit.h>
                

2. Configure APIKEY

Refer to Project Configuration Instructions.

3. Define NavinfoTrafficIncidentSearch

Define the traffic event search object NavinfoTrafficIncidentSearch and inherit the search protocol <NavinfoTrafficSearchDelegate >.

4. Construct NavinfoTrafficIncidentSearch

Construct an event search object NavinfoTrafficIncidentSearch and set the proxy.

                    _incidentSearch = [[NavinfoTrafficIncidentSearch alloc] init];
                    _incidentSearch.delegate = self;
                

5. Set the front event search query parameters

The request parameter class of the peripheral event search query is NavinfoTrafficAroundQuery, and the two parameters of poiName (POI name) lonlat (latitude and longitude) cannot be empty at the same time. For other non-essential parameters, please refer to the API documentation.

                    NavinfoTrafficAroundQuery *query = [NavinfoTrafficAroundQuery new];
                    query.poiName = @"Peking University";
                    query.lonlat = [[NavinfoLonlat alloc] initWith:11635646 latitude:3992317 gbType:NavinfoGbTypeG02];
                

6. Initiate search query parameters

Send a peripheral event search query by calling the aroundIncidentSearch method of NavinfoTrafficIncidentSearch.

                    [_incidentSearch aroundIncidentSearch:query];
                

7. Processing data in callbacks

Proxy method when the query is successful.

                    - (void)onTrafficIncidentAroundSearch:(NavinfoTrafficIncidentSearch * _Nonnull)incidentSearch
                    result:(NavinfoTrafficIncidentResult * _Nullable)result
                    error:(NSError * _Nullable)error
                

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

Description:

For the parameter information, please refer to [Road Event Voice Broadcast].

                    - (void)onTrafficIncidentAroundSearch:(NavinfoTrafficIncidentSearch *)incidentSearch result:(NavinfoTrafficIncidentResult *)result error:(NSError *)error {
                        NSLog(@"----> onTrafficIncidentAroundSearch");
                        for (NSInteger index = 0; index > result.totalCount; index++) {
                            NavinfoTIncidentData *data = result.contents[index];
                            NSString *lonlatStr = [NavinfoLonlat toSringWithLonlats:@[data.lonlat]];
                            NSLog(@"\nID=%@, \nInfo=%@, \nlonlat=%@, \nroadName=%@, \nroadDir=%@, \nreli=%@, \nsTime=%@, \neTime=%@, \nuTime=%@, \ntype=%ld",
                                data.eventId,
                                data.eventInfo,
                                lonlatStr,
                                data.roadName,
                                data.roadDirection,
                                data.reliability,
                                data.startTime,
                                data.expectExpireTime,
                                data.updataTime,
                                data.eventType);
                        }
                    }
                

8. Processing failed queries

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

1. Import header files

                        #import <NavinfoKit/NavinfoKit.h>
                    

2. Configure APIKEY

Refer to Project Configuration Instructions.

3. Define NavinfoTrafficIncidentSearch

Define the traffic event search object NavinfoTrafficIncidentSearch and inherit the search protocol <NavinfoTrafficSearchDelegate >.

4. Construct NavinfoTrafficIncidentSearch

Construct an event search object NavinfoTrafficIncidentSearch and set the proxy.

                        _incidentSearch = [[NavinfoTrafficIncidentSearch alloc] init];
                        _incidentSearch.delegate = self;
                    

5. Set navigation line event search query parameters

The request parameter class of the navigation line event search query is NavinfoTrafficNaviQuery, and the lonlats (latitude and longitude string) is a mandatory parameter.

Please refer to the API documentation for other non-essential parameters.

                        NavinfoTrafficNaviQuery *query = [NavinfoTrafficNaviQuery new];
                        NavinfoLonlat *lonlat1 = [[NavinfoLonlat alloc] initWith:11623050 latitude:4007837 gbType:NavinfoGbTypeG02];
                        NavinfoLonlat *lonlat2 = [[NavinfoLonlat alloc] initWith:11623058 latitude:4007822 gbType:NavinfoGbTypeG02];
                        NavinfoLonlat *lonlat3 = [[NavinfoLonlat alloc] initWith:11623069 latitude:4007801 gbType:NavinfoGbTypeG02];
                        NavinfoLonlat *lonlat4 = [[NavinfoLonlat alloc] initWith:11623114 latitude:4007706 gbType:NavinfoGbTypeG02];
                        NavinfoLonlat *lonlat5 = [[NavinfoLonlat alloc] initWith:11623138 latitude:4007622 gbType:NavinfoGbTypeG02];
                        query.lonlats = @[lonlat1,lonlat2,lonlat3,lonlat4,lonlat5];
                    

6. Initiate search query parameters

Initiate a navigation line event search query by calling the naviIncidentSearch method of NavinfoTrafficIncidentSearch.

                        [_incidentSearch naviIncidentSearch:query];
                    

7. Processing data in callbacks

Proxy method when the query is successful.

                        - (void)onTrafficIncidentNaviSearch:(NavinfoTrafficIncidentSearch * _Nonnull)incidentSearch
                        result:(NavinfoTrafficIncidentResult * _Nullable)result
                        error:(NSError * _Nullable)error;
                    

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

Description:

For the parameter information, please refer to [Road Event Voice Broadcast].

                        - (void)onTrafficIncidentNaviSearch:(NavinfoTrafficIncidentSearch *)incidentSearch result:(NavinfoTrafficIncidentResult *)result
                        error:(NSError *)error {
                            NSLog(@"----> onTrafficIncidentNaviSearch");
                            for (NSInteger index = 0; index < result.totalCount; index++) {
                            NavinfoTIncidentData *data = result.contents[index];
                            NSString *lonlatStr = [NavinfoLonlat toSringWithLonlats:@[data.lonlat]];
                                NSLog(@"\nID=%@, \nInfo=%@, \nlonlat=%@, \nroadName=%@, \nroadDir=%@, \nreli=%@, \nsTime=%@, \neTime=%@, \nuTime=%@, \ntype=%ld",
                                    data.eventId,
                                    data.eventInfo,
                                    lonlatStr,
                                    data.roadName,
                                    data.roadDirection,
                                    data.reliability,
                                    data.startTime,
                                    data.expectExpireTime,
                                    data.updataTime,
                                    data.eventType);
                            }
                        }
                    

8. Processing failed queries

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

TOP