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

Current road name label can display names of adjacent footpaths #2259

Closed
1ec5 opened this issue Oct 17, 2019 · 1 comment · Fixed by #2635
Closed

Current road name label can display names of adjacent footpaths #2259

1ec5 opened this issue Oct 17, 2019 · 1 comment · Fixed by #2635
Labels
bug Something isn’t working topic: instructions

Comments

@1ec5
Copy link
Contributor

1ec5 commented Oct 17, 2019

When the user drives down a road that has a named footpath or bike path running alongside it, the current road name label can display that path’s name instead of the road’s. The SDK queries the map based on a location snapped to the route line, so normally it would be fine if some other kind of pathway runs alongside the roadway. But an incorrect result could still occur if the user has deviated far enough from the route that snapping ceases, but not far enough that the user gets rerouted, or if they’ve driven past the destination.

RouteMapViewController.labelCurrentRoad(at:for:) lays down a line layer bound to the Streets source and ensures that it gets obscured by the original style’s own road layers:

if let mapboxStreetsSource = streetsSources.first, style.layer(withIdentifier: roadLabelLayerIdentifier) == nil {
let streetLabelLayer = MGLLineStyleLayer(identifier: roadLabelLayerIdentifier, source: mapboxStreetsSource)
streetLabelLayer.sourceLayerIdentifier = mapboxStreetsSource.roadLabelLayerIdentifier
streetLabelLayer.lineOpacity = NSExpression(forConstantValue: 1)
streetLabelLayer.lineWidth = NSExpression(forConstantValue: 20)
streetLabelLayer.lineColor = NSExpression(forConstantValue: UIColor.white)
style.insertLayer(streetLabelLayer, at: 0)
}

The line style layer needs to have a source layer of road (to avoid snagging other named features like rivers). The layer should also have a filter that requires class to be an appropriate value. The set of appropriate values depends on the current route step’s mode, as seen in mapbox/mapbox-navigation-android#2227 (comment).

/cc @mapbox/navigation-ios

@1ec5
Copy link
Contributor Author

1ec5 commented Sep 16, 2020

@avi-c discovered that the lack of filtering also results in very poor performance in areas with lots of overlapping non-roads on the map, such as in urban areas of Japan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working topic: instructions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant