如何在 skobbler 导航中启用 header next-turn 视图

How to enable header next-turn view in skobbler navigation

在演示版中,我注意到 header 带有箭头,指向下一个转弯,以及距离和用户需要转弯的下一条街道的名称。

截图如下:

我无法从文档或演示应用程序中弄清楚如何启用它。 有什么建议吗?

首先,必须实现SKNavigationDelegate和SKRoutingDelegate。

别忘了设置代表:

[SKRoutingService sharedInstance].routingDelegate = self;
[SKRoutingService sharedInstance].navigationDelegate = self;

还有一段非常重要的代码:

SKAdvisorSettings* advisorSettings = [[SKAdvisorSettings alloc]init];
[SKRoutingService sharedInstance].advisorConfigurationSettings = advisorSettings;
[Constants shared].route.requestAdvices=YES;

然后,在计算出路线后,您就可以玩这些方法了:

-(void)routingService:(SKRoutingService *)routingService didChangeNextStreetName:(NSString *)nextStreetName streetType:(SKStreetType)streetType countryCode:(NSString *)countryCode
{
// This method returns the Name of the next street
_txtNextStreetName.text = [NSString stringWithFormat:@"%@",nextStreetName];
}

// This method returns visual guidance to the next turn on the road
-(void)routingService:(SKRoutingService *)routingService didChangeCurrentAdviceImage:(UIImage *)adviceImage withLastAdvice:(BOOL)isLastAdvice
{
[_imgVisualAdvice setImage:adviceImage];
}

// 和距离

-(void)routingService:(SKRoutingService *)routingService didChangeSecondaryVisualAdviceDistance:(int)distance withFormattedDistance:(NSString *)formattedDistance
{

    _txtNextStreetDistance.text = [NSString StringWithFormat:@"%@",formattedDistance];

}