[QUESTION]: Drawing a route with different colors for different legs
I am trying to draw a route on a NavigationMapView using .showcase, while coloring each route leg differently based on a specific logic. Imagine Google Maps when using public transport. Each leg of the route will be colored in a color matching the transportation mode. I am trying to do something similar using mapbox. After trying for a long time I have not found a way to reliably color legs differently. I could also not find a way to reliably color different routes differently, except for the difference between alternatives and main route.
Is there a way to do that currently? If not, can this be added in a future update? It seems so simple...
Unfortunately, there is no direct API to set different colors for each leg of a route at the moment.
There is NavigationMapViewDelegate's method that allows to return LineLayer for a specific route line, given a layer identifier and a source identifier navigationMapView(_:routeLineLayerWithIdentifier:sourceIdentifier:).
Here's an example: Route-Lines-Styling.swift.
Note: This method is currently unavailable in v3, but it will be added soon.
@volkdmitri Thank you for your reply. Unfortunately, I knew about that method, but can't use it, because the layer and source identifiers are unknown. When drawing routes on the NavigationMapView there is no way to save those identifiers in order to use `[navigationMapView(_:routeLineLayerWithIdentifier:sourceIdentifier:)]' to style the specific route matching the identifier.
Adding a simple way to style each leg or route would certainly be great for many Mapbox applications. Please think about adding that in a future update.