mapbox / mapbox/mapbox-navigation-ios
Unable to override style for main route in NavigationViewController when routeLineTracksTraversal is set to true.
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 918
- Forks
- 326
- Avg merge
- 1h 16m
- Merged PRs (30d)
- 3
Description
**Mapbox Navigation SDK version:** `1.1.0`
### Steps to reproduce
Implement such `NavigationViewControllerDelegate` method:
```swift
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the NavigationViewControllerDelegate method mainRouteStyleLayerWithIdentifier and follow how routeLineTracksTraversal updates the main route and casing during active guidance. Reproduce the provided setup with a custom lineColor, then verify that the custom style remains in effect instead of being replaced by default congestion styling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100