3

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.

Chanaka NZ
  • 127
  • 1
  • 8

1 Answers1

4

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.

langsmith
  • 2,529
  • 1
  • 11
  • 13
  • The label name `road-label` could resolve my problem. Thank you very much for the explanation. Earlier I tried printing only SymbolLayers but I could only found the layers like `road-label-street, road-label-secondary-tertiary, road-label-primary, road-label-motorway-trunk, road-shields-black, road-shields-white, rail-label` But none of them worked for me. The labelId `road-label` solved my problem. – Chanaka NZ Sep 01 '20 at 02:10
  • Awesome, glad that you got it working. Happy building with Mapbox! Please consider marking my answer as correct :) – langsmith Sep 01 '20 at 17:54