-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Navigation with waypoints, can't change leg color anymore in 1.0.0 #2678
Comments
Possibly related: #2595. |
As discussed in #2377 (comment), the new |
Sorry but I don't really understand, you decided that |
No, it seems to have been an oversight. We’re tracking this issue as a regression. In fact, we were planning on introducing an explicit option to give different routes and legs different colors in a future minor release, something more explicit than how Once #2623 lands, there will be a workaround in the form of specifying a different polyline feature for each leg, but until then, I don’t know of a straightforward workaround. |
I get it, thank you. Can you provide me with some explanation on how to specify a polyline feature for each leg ? So i can implement it when #2623 will land |
Hi @1ec5 , Some help will be appreciated |
Now that #2623 has landed, you can implement mapbox-navigation-ios/MapboxNavigation/NavigationMapView.swift Lines 898 to 903 in 94a29e3
This issue essentially tracks bringing back that /ref #2377 (comment) |
Hi @1ec5 unfortunately this doesn't work. I tried with this code: func navigationViewController(_ navigationViewController: NavigationViewController, mainRouteStyleLayerWithIdentifier identifier: String, source: MGLSource) -> MGLStyleLayer? {
print(source)
let line = MGLLineStyleLayer(identifier: identifier, source: source)
line.lineWidth = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", MBRouteLineWidthByZoomLevel)
line.lineOpacity = NSExpression(forConditional: NSPredicate(format: "isCurrentLeg == true"),
trueExpression: NSExpression(forConstantValue: 1),
falseExpression: NSExpression(forConstantValue: 0))
line.lineColor = NSExpression(format: "TERNARY(isAlternateRoute == true, %@, MGL_MATCH(congestion, 'low' , %@, 'moderate', %@, 'heavy', %@, 'severe', %@, %@))", self.mapView?.routeAlternateColor as! CVarArg, self.mapView?.trafficLowColor as! CVarArg, self.mapView?.trafficModerateColor as! CVarArg, self.mapView?.trafficHeavyColor as! CVarArg, self.mapView?.trafficSevereColor as! CVarArg, self.mapView?.trafficUnknownColor as! CVarArg)
line.lineJoin = NSExpression(forConstantValue: "round")
return line
} But this is called only once with the whole navigation route, not for each leg. Concerning the implementation of
And because the delegate don't have the legIndex as a parameter, I can't manually set the attribute of "isCurrentLeg". |
You’re right, I don’t think there’s a suitable workaround at this time. I’m recommending to the team that we prioritize a fix for the original regression by integrating the old leg-based coloring feature into the line gradient so that the deemphasized legs will work regardless of the |
Thank you @1ec5 |
Currently is blocked by PR #2833. We can return to this ticket after this PR lands. |
@azarovalex #2833 is merged now. We could start working on this issue. |
@abouroubi You can now use
You can call |
Thanks @azarovalex , I'll check it as soon as it's available. |
Hello @azarovalex
I assume you are talking about this function to update the active leg index ? func navigationViewController(_ navigationViewController: NavigationViewController, didArriveAt waypoint: Waypoint) -> Bool Unfortunately the So it's still difficult to de-emphasize the inactive legs in the iOS Navigation SDK. |
Hi @abouroubi , the way to change the color of current leg is the same as before in the following ways:
Tis pr provides some examples to show how it work with the color. I hope it's helpful to you. |
Mapbox Navigation SDK version: 1.0.0
I was using the SDK version 1.0.0-alpha1, I'm starting navigation with 3 waypoints each time, with the 1.0.0-alpha1, if I wanted to change the color of the current leg, and diffenrentiate it to otehr legs I used this code, and it worked:
The first line controled the color of the remaining legs, and the second line was the color of the current active leg (where the user is).
After updating to 1.0.0, this doesn't work anymore, the whole route have the second color.
The text was updated successfully, but these errors were encountered: