Doz
Doz

Reputation: 7149

How do I change visual advisor colors in Skobbler SDK for iOS

I am trying to work out how I would change the visual advice (arrows) colors for the navigation aspect of Skobbler SDK for iOS. I would like to customize aspects of the visual advice color-wise...

I have the following:

    let configAdvice = SKVisualAdviceConfiguration.visualAdviceColor()
    configAdvice.countryCode = "US"
    configAdvice.streetType = SKStreetType.Secondary
    configAdvice.routeStreetColor = UIColor.blackColor()
    configAdvice.allowedStreetColor = UIColor.blackColor()
    configAdvice.forbiddenStreetColor = UIColor.blackColor()
    //        config.routeStreetColor = [UIColor colorWithHex:color alpha:1.0];
    //        config.allowedStreetColor = [UIColor colorWithHex:color alpha:0.0f];
    //        config.forbiddenStreetColor = [UIColor colorWithHex:color alpha:0.0f];

    SKRoutingService.sharedInstance().visualAdviceConfigurations = [configAdvice]

    let settings: SKAdvisorSettings = SKAdvisorSettings()
    let currentLanguage: String = "en_us"
    settings.advisorVoice = currentLanguage
    settings.advisorType = .AudioFiles
    SKRoutingService.sharedInstance().advisorConfigurationSettings = settings

The result is: image

As you can see the arrow is white which is hard to see. So I'm not sure why the code isn't reflected in the visuals...

Upvotes: 1

Views: 146

Answers (1)

Ando
Ando

Reputation: 11429

Visual instructions: listen to didChangeFirstVisualAdvice. Inside the SKRouteState parameter you will find information about the:

  • Path to the current (first) visual advice: currentVisualAdvicePath (if you want a coloured image use firstVisualAdviceImageWithColor)
  • Path to the next (second) visual advice: secondaryVisualAdvicePath (if you want a coloured image use secondVisualAdviceImageWithColor)

To set the colour scheme for the "coloured advices" use the following visualAdviceConfigurations setting:

SKVisualAdviceConfiguration *visualAdviceColor1 = [SKVisualAdviceConfigurationvisualAdviceColor];
visualAdviceColor1.countryCode = @“DE";
visualAdviceColor1.streetType = SKStreetTypeSecondary;
visualAdviceColor1.routeStreetColor = [UIColor whiteColor];
visualAdviceColor1.allowedStreetColor = [UIColor grayColor];
visualAdviceColor1.forbiddenStreetColor = [UIColor blackColor];
[SKRoutingServicesharedInstance].visualAdviceConfigurations = @[visualAdviceColor1];

Here is the code used in demo app (the SDKTools project):

- (void)updateVisualAdviceSign {
    SKTNavigationVisualAdviceView *adviceView = self.mainView.navigationView.visualAdviceView;
    if (self.navigationInfo.firstAdvice) {
        if (self.navigationInfo.firstAdviceIsLast) {
            NSString *imageName = self.colorScheme[[SKTNavigationUtils destinationImageNameForStreetType:self.navigationInfo.nextStreetType]];
            imageName = [@"Icons/DestinationImages" stringByAppendingPathComponent:imageName];
            adviceView.signImageView.image = [UIImage navigationImageNamed:imageName];
        } else {
            SKVisualAdviceConfiguration *config = [self configurationForStreetType:self.navigationInfo.nextStreetType];
            adviceView.signImageView.image = [[SKRoutingService sharedInstance] visualAdviceImageForRouteAdvice:self.navigationInfo.firstAdvice color:config];
        }
    } else {
        adviceView.signImageView.image = nil;
    }
}

and:

- (SKVisualAdviceConfiguration *)configurationForStreetType:(SKStreetType)streetType {
    NSString *name = [SKTNavigationUtils adviceSignColorNameForStreetType:streetType];
    uint32_t color = [self.colorScheme[name] unsignedIntValue];
    SKVisualAdviceConfiguration *config = [SKVisualAdviceConfiguration visualAdviceColor];
    config.streetType = streetType;
    config.countryCode = self.navigationInfo.currentCountryCode;
    config.routeStreetColor = [UIColor colorWithHex:color alpha:1.0];
    config.allowedStreetColor = [UIColor colorWithHex:color alpha:0.0f];
    config.forbiddenStreetColor = [UIColor colorWithHex:color alpha:0.0f];

    return config;
}

Upvotes: 1

Related Questions