Search code examples
androidmapboxmapbox-androidmapbox-android-nav

How to draw a polyline under street names in MapBox Android


Currently I'm drawing polyline using LineLayer and adding it to the map using style.addLayer(lineLayer). I noticed that polyline is drawn on top of the street labels. I want to get it under the labels in the map.

I found the method style.addLayerBelow(lineLayer, <belowLayerId>) method will resolve this but couldn't find the correct id to use as belowLayerId. Can anyone please help me on this matter.


Solution

  • What style are you using? You can view the style in Mapbox Studio (https://studio.mapbox.com) and see the order of the style's layers. If you're using Mapbox Streets Style.MAPBOX_STREETS, the street label id is road-label:

    enter image description here

    Or you can print each layer ID in the Android Studio logcat to see the layer order. The second code block area in https://docs.mapbox.com/android/maps/overview/styling-map/#retrieving-a-map-layer has info about printing out all of the layers in the Style.