@@ -206,7 +206,7 @@ extension NavigationMapView {
206206 return
207207 }
208208 let newFractionTraveled = self . preFractionTraveled + traveledDifference * timePassedInMilliseconds. truncatingRemainder ( dividingBy: 1000 ) / 1000
209- guard let mainRouteLayerGradient = self . routeLineGradient ( routeProgress. route, fractionTraveled: newFractionTraveled) else { return }
209+ guard let mainRouteLayerGradient = self . routeLineGradient ( routeProgress. route, fractionTraveled: newFractionTraveled, isMain : true ) else { return }
210210 let mainRouteCasingLayerGradient = self . routeCasingGradient ( newFractionTraveled)
211211
212212 guard var mainRouteLineLayer = try ? self . mapView. style. getLayer ( with: mainRouteLayerIdentifier, type: LineLayer . self) . get ( ) ,
@@ -217,7 +217,7 @@ extension NavigationMapView {
217217 } )
218218 }
219219
220- func routeLineGradient( _ route: Route , fractionTraveled: Double ) -> [ Double : UIColor ] ? {
220+ func routeLineGradient( _ route: Route , fractionTraveled: Double , isMain : Bool ) -> [ Double : UIColor ] ? {
221221 var gradientStops = [ CGFloat: UIColor] ( )
222222
223223 /**
@@ -250,7 +250,7 @@ extension NavigationMapView {
250250 // Get congestion color for the stop.
251251
252252 let congestionLevel = feature. properties ? [ CongestionAttribute] as? String
253- let associatedCongestionColor = congestionColor ( for: congestionLevel)
253+ let associatedCongestionColor = congestionColor ( for: congestionLevel, isMain : isMain )
254254
255255 // Measure the line length of the traffic segment.
256256 let lineString = feature. geometry. value as? LineString
@@ -267,7 +267,7 @@ extension NavigationMapView {
267267 gradientStops [ segmentEndPercentTraveled. nextDown] = associatedCongestionColor
268268
269269 if index + 1 < congestionSegments. count {
270- gradientStops [ segmentEndPercentTraveled. nextUp] = congestionColor ( for: congestionSegments [ index + 1 ] . properties ? [ " congestion " ] as? String )
270+ gradientStops [ segmentEndPercentTraveled. nextUp] = congestionColor ( for: congestionSegments [ index + 1 ] . properties ? [ " congestion " ] as? String , isMain : isMain )
271271 }
272272
273273 continue
@@ -297,7 +297,7 @@ extension NavigationMapView {
297297 gradientStops [ segmentEndPercentTraveled. nextDown] = associatedCongestionColor
298298
299299 if index + 1 < congestionSegments. count {
300- gradientStops [ segmentEndPercentTraveled. nextUp] = congestionColor ( for: congestionSegments [ index + 1 ] . properties ? [ " congestion " ] as? String )
300+ gradientStops [ segmentEndPercentTraveled. nextUp] = congestionColor ( for: congestionSegments [ index + 1 ] . properties ? [ " congestion " ] as? String , isMain : isMain )
301301 }
302302 }
303303
@@ -343,18 +343,33 @@ extension NavigationMapView {
343343 /**
344344 Given a congestion level, return its associated color.
345345 */
346- func congestionColor( for congestionLevel: String ? ) -> UIColor {
347- switch congestionLevel {
348- case " low " :
349- return trafficLowColor
350- case " moderate " :
351- return trafficModerateColor
352- case " heavy " :
353- return trafficHeavyColor
354- case " severe " :
355- return trafficSevereColor
356- default :
357- return trafficUnknownColor
346+ func congestionColor( for congestionLevel: String ? , isMain: Bool ) -> UIColor {
347+ if isMain {
348+ switch congestionLevel {
349+ case " low " :
350+ return trafficLowColor
351+ case " moderate " :
352+ return trafficModerateColor
353+ case " heavy " :
354+ return trafficHeavyColor
355+ case " severe " :
356+ return trafficSevereColor
357+ default :
358+ return trafficUnknownColor
359+ }
360+ } else {
361+ switch congestionLevel {
362+ case " low " :
363+ return alternativeTrafficLowColor
364+ case " moderate " :
365+ return alternativeTrafficModerateColor
366+ case " heavy " :
367+ return alternativeTrafficHeavyColor
368+ case " severe " :
369+ return alternativeTrafficSevereColor
370+ default :
371+ return alternativeTrafficUnknownColor
372+ }
358373 }
359374 }
360375
0 commit comments