Mapbox GL JS:在图层上方显示地图标签?

Mapbox GL JS: Display map labels above layer?

我正在使用带有 Mapbox Streets 基础层的 Mapbox GL JS。我添加了一个带有白色边框和透明填充的多边形图层,但我发现很难阅读多边形图层下方的底图标签。查看标签如何被白色边框覆盖:

有什么方法可以确保标签位于多边形图层之上,或者至少不会被它遮挡?

我的代码如下所示:

var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v9',
    center: [-2.839, 54.579],
    zoom: 4
});
map.on('load', function () {
    map.addSource('constituencies', {
        'type': 'vector',
        'url': 'mapbox://pcsu.xxx'
    });
    var constituencyLayer = map.addLayer({
        'id': 'constituencies',
        'source': 'constituencies',
        'source-layer': 'constituencies',
        'type': 'fill',
        'paint': {
            'fill-color': 'rgba(162,181,205,0.6)',
            'fill-outline-color': 'white'
        },
        'layout': {
            'visibility': 'visible'
        }
    });

看看 map.addLayer(layer, [before])this Mapbox example and use the second argument。如果这个层 before 存在,新层将被放置 before/below 它。我认为这里的参数命名有点混乱。

最低标签层的名称取决于样式。大多数时候你在寻找 housenum-labelMapbox github issues 中也讨论了如何简化此过程,例如通过引入占位符层。