首页 / 浏览问题 / WebGIS / 问题详情
请教一下,在非聚合增加一个 unclustered-label图层,但是这字体只能显示成这样吗,能重一点或者加粗么?并且要添加一个有圆角的背景颜色,该如何添加?
4EXP 2024年06月02日

目前显示成这样,很细很浅看不清,还要设置背景颜色,如何设置?

1个回答

您好,字体太细,可以调大字体,不设置文本光晕。如果您想设置圆角背景框,可以换成标签加circle的方式
876EXP 2024年06月04日
应该如何设置?能给一个简单的例子么?
我这边测试,MapboxGL的标签中没有圆角矩形这一种,可以用图标替代,这样不设置文本光晕直接调整字体大小即可。
map.loadImage('../../examples/img/image.png', function(error, image) {
                if (error)
                    throw error;
                map.addImage('label-black', image);
                map.addLayer({
                    id: "unclustered-label",
                    type: "symbol",
                    source: "earthquakes",
                    filter: ["!", ["has", "point_count"]],
                    layout: {
                        "icon-image": "label-black",
                        "icon-size": 0.5,
                        "icon-anchor": "center",
                        'text-field': ["get", "location"],
                        'text-anchor': 'center' // 文字锚点
                    },
                    'paint': {
                        'text-color': '#000000', // 文字颜色
                    }
                });
            });
热门文章
关注我们
...