Skip to content
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

[QUESTION]: Drawing a route with different colors for different legs #4647

Open
JanTG1 opened this issue May 16, 2024 · 2 comments
Open

[QUESTION]: Drawing a route with different colors for different legs #4647

JanTG1 opened this issue May 16, 2024 · 2 comments

Comments

@JanTG1
Copy link

JanTG1 commented May 16, 2024

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...

@volkdmitri
Copy link
Contributor

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.

@JanTG1
Copy link
Author

JanTG1 commented May 28, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants