mapbox-navigation-ios icon indicating copy to clipboard operation
mapbox-navigation-ios copied to clipboard

Showing street's names on top of route layer

Open hastiranjkesh opened this issue 8 years ago • 3 comments

I'm using Mapbox Navigation SDK version 0.22 and I also checked the latest version and I still have a problem. I need to show streets' names on top of the routing layer in the navigation map view. So I found a solution: I know the layer identifier that contains streets' names in my map view style is "road_direction_ft_brg" and based on the code in showRoutes method in NavigationMapView class, I found out the routing layer is added on top of it, so I changed the code:

        for layer in style.layers.reversed() {
            if !(layer is MGLSymbolStyleLayer) &&
                layer.identifier != arrowLayerIdentifier && layer.identifier != arrowSymbolLayerIdentifier && layer.identifier != arrowCasingSymbolLayerIdentifier && layer.identifier != arrowLayerStrokeIdentifier && layer.identifier != waypointCircleIdentifier {
                
                //"road_direction_ft_brg" layer  in style is the layer contains street's names
                if layer.identifier == "admin-country" || layer.identifier == "admin-province" || layer.identifier == "buildings" {
                    continue
                }
                //when it reaches to this point the layer identifier is "road_direction_ft_brg"
                style.insertLayer(line, below: layer)
                style.insertLayer(lineCasing, below: line)
                break
            }
        }

Because "road_direction_ft_brg" layer is after "admin-country", "admin-province" and "buildings" layers, I've changed the for statement to continue until it gets to "road_direction_ft_brg" layer then route layer adds below the "road_direction_ft_brg" layer. Am I right? or Is there any better way to do that?

hastiranjkesh avatar Oct 28 '18 16:10 hastiranjkesh

NavigationMapView places the route line layers below symbol layers. Try inserting your street name layer to the style before showRoutes(_:legIndex:) is called. That method will start from the top of the stack of layers and iterate towards the bottom of the stack, inserting the route line layers below the first non-symbol layer it finds.

https://github.com/mapbox/mapbox-navigation-ios/blob/8de6063b28b0db2ce764cb74f5d5e927f65611ab/MapboxNavigation/NavigationMapView.swift#L453-L460

1ec5 avatar Oct 30 '18 23:10 1ec5

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 20 '20 16:07 stale[bot]

Stale.

stale[bot] avatar Jul 29 '20 22:07 stale[bot]