如何在mapbox-gl中为图层文本字段添加背景颜色,或者如何在文本字段中添加背景框
map.addLayer({
"id": "markers",
"type": "symbol",
"source": "markers",
"layout": {
"icon-image": "{marker-symbol}-15",
"text-field": "{title}",
"text-font": ["Open Sans Semibold", "Arial Unicode MS Bold"],
"text-offset": [0, 0.6],
"text-anchor": "top"
}
});
Run Code Online (Sandbox Code Playgroud)
虽然我也不知道如何绘制背景框,但我们可能正在寻找相同的东西,即隐藏自定义标签下方的任何其他文本,使其弹出并更清晰。如果是这样,我确实发现您可以添加一个“光环”来达到预期的效果。
"layout": {
"icon-image": symbol + "-15",
"icon-allow-overlap": true,
"text-field": symbol,
"text-font": ["Open Sans Bold", "Arial Unicode MS Bold"],
"text-size": 11,
"text-transform": "uppercase",
"text-letter-spacing": 0.05,
"text-offset": [0, 1.5]
},
"paint": {
"text-color": "#202",
"text-halo-color": "#fff",
"text-halo-width": 2
},
Run Code Online (Sandbox Code Playgroud)
这是从他们网站上的这个例子中获取的。
| 归档时间: |
|
| 查看次数: |
1311 次 |
| 最近记录: |