您现在的位置:

道路模糊搜

1. 导入头文件

                        #import <NavinfoKit/NavinfoKit.h> 
                

2. 配置APIKEY

参考工程配置说明

3. 定义 NavinfoTrafficRTICSearch

定义路况搜索对象 NavinfoTrafficRTICSearch,并继承搜索协议<NavinfoTrafficSearchDelegate >。

4. 构造 NavinfoTrafficRTICSearch

构造事件搜索对象 NavinfoTrafficRTICSearch,并设置代理。

                    _rticSearch = [NavinfoTrafficRTICSearch new];
                    _rticSearch.delegate = self;                    
                

5. 设置周边道路模糊搜索查询参数

道路模糊搜索查询的请求参数类为 NavinfoTrafficRoadNameQuery,keyword(关键字)为必填写参数,其它非必要参数请参考API文档。

                    NavinfoTrafficRoadNameQuery *query = [NavinfoTrafficRoadNameQuery new];
                    query.keyword = @"北";
                    query.cityName = @"beijing";                    
                

6. 发起搜索查询参数

通过调用 NavinfoTrafficRTICSearch的 roadNameSearch方法发起道路模糊搜索查询。

                    [_rticSearch roadNameSearch:query];
                

7. 在回调中处理数据

当查询成功时,代理方法。

                    - (void)onTrafficRTICRoadNameSearch:(NavinfoTrafficRTICSearch * _Nonnull)rticSearch
                    result:(NavinfoTrafficRoadNameResult * _Nullable)result
                    error:(NSError * _Nullable)error;
                

其中NavinfoTrafficRTICResult返回,NSError 为nil,此时可获取查询结果。

说明:

1) 通过 rticSearch 获路路况搜索实例。

2) 通过 result.roadNames 获路名集合。

                    - (void)onTrafficRTICRoadNameSearch:(NavinfoTrafficRTICSearch *)rticSearch result:(NavinfoTrafficRoadNameResult *)result error:(NSError *)error {
                        NSLog(@"---->  onTrafficRTICRoadNameSearch: %@", result.roadNames[0]);
                    }                    
                

8. 处理失败查询

当检索失败时,Error 会返回,通过该回调函数获取产生的失败的原因。

返回顶部