Search code examples
iosobjective-cxcodeskmaps

How to enable header next-turn view in skobbler navigation


in demo version, I noticed header with arrows, pointing to next turn, together with distance and the name of the next street where the user needs to turn.

here is the screenshot: enter image description here

I cannot figure out from documentation nor demo app how to enable it. Anny suggestions?


Solution

  • First of all, SKNavigationDelegate and SKRoutingDelegate must be implemented.

    Don't forget to set delegates:

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

    And VERY important piece of code:

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

    Then, after the route is calculated, you'll be able to play with these methods:

    -(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];
    }
    

    // And the distance

    -(void)routingService:(SKRoutingService *)routingService didChangeSecondaryVisualAdviceDistance:(int)distance withFormattedDistance:(NSString *)formattedDistance
    {
    
        _txtNextStreetDistance.text = [NSString StringWithFormat:@"%@",formattedDistance];
    
    }