发出标签偏置线

时间:2019-07-22 19:50:21

标签: mapbox mapbox-gl-js mapbox-gl

我正在尝试绘制带有标签的线,但我需要将它们偏移。通过“ line-offset”绘画属性很容易做到这一点。如何偏移标签,使它们与线条对齐?

我尝试在标签层上使用“文本偏移”,但是该单位在“ em”中,其中标签偏移在“像素”中。

工作示例: https://stackblitz.com/edit/typescript-hevpqy?file=data%2Flayers.json

所需的输出示例: enter image description here

1 个答案:

答案 0 :(得分:0)

此问题似乎是由您设置的pitch引起的:60。

当pitch为0时,很容易找到text-offsetline-widthline-offset的组合来使文本保持在行内:

enter image description here

但是只要我们倾斜相机:

enter image description here

我怀疑这是mapbox-gl-js中的错误或限制。您可以提出问题here