mapbox-navigation-ios icon indicating copy to clipboard operation
mapbox-navigation-ios copied to clipboard

Unable to override style for main route in NavigationViewController when routeLineTracksTraversal is set to true.

Open MaximAlien opened this issue 5 years ago • 0 comments

Mapbox Navigation SDK version: 1.1.0

Steps to reproduce

Implement such NavigationViewControllerDelegate method:

func navigationViewController(_ navigationViewController: NavigationViewController, mainRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
    let layer = MGLLineStyleLayer(identifier: identifier, source: source)
    layer.predicate = NSPredicate(format: "isAlternateRoute == false")
    layer.lineColor = NSExpression(forConstantValue: #colorLiteral(red: 0.4666666687, green: 0.7647058964, blue: 0.2666666806, alpha: 1))
    layer.lineWidth = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", MBRouteLineWidthByZoomLevel.multiplied(by: 0.8))
    layer.lineJoin = NSExpression(forConstantValue: "round")
    layer.lineCap = NSExpression(forConstantValue: "miter")

    return layer
}

Set NavigationViewController.routeLineTracksTraversal = true, start active guidance navigation and observe behavior.

Expected behavior

NavigationViewController should retain any modifications which were added to main route line during active guidance. Since MGLLineStyleLayer.lineColor property is set to custom color it should be used instead of default congestion levels.

Actual behavior

NavigationViewController overwrites modifications which were applied to main route/casing during active guidance.

MaximAlien avatar Nov 25 '20 23:11 MaximAlien