Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
463 views
in Technique[技术] by (71.8m points)

javascript - Openlayers V6 Backgroundfill文本仅适用于最后一个文本元素(Openlayers V6 Backgroundfill text only applies on last text element)

A couple of weeks ago we've updated our software with the newest openlayers version (6.1.1).

(几周前,我们已经使用最新的openlayers版本(6.1.1)更新了我们的软件。)

The previous version was 5.3.0, where we didn't experience the problem.

(先前的版本是5.3.0,我们没有遇到这个问题。)

We have a vector layer, and for each feature, we draw the name on the map.

(我们有一个矢量层,并为每个要素在地图上绘制名称。)

We apply style to these texts, and also add a background, so the text is always readable.

(我们将样式应用于这些文本,并添加背景,因此文本始终可读。)

var fontColor = "black";
var backgroundColor = "white";
var backgroundFill = new ol.style.Fill({
   color: backgroundColor
});
var text = new ol.style.Text({ fill: new ol.style.Fill({ color: fontColor }), backgroundFill: backgroundFill, text: "text" });
labelStyle.setText(text);

Somehow in the newest version (6.1) of openlayers, the backgroundFill is only applied on the last text element.

(在最新版本的openlayers(6.1)中,backgroundFill仅适用于最后一个文本元素。)

If I randomly pick a fontColor which will be differrent for each feature, this is correctly applied on each feature.

(如果我随机选择一个fontColor,它将针对每个功能有所不同,则可以正确地将其应用于每个功能。)

Has the functionality of the backgroundFill-property changed?

(backgroundFill-property的功能是否已更改?)

Or is there another way to apply backgroundFill with the newest version of Openlayers so that it is applied to all elements?

(还是有另一种方法可以将backgroundFill与最新版本的Openlayers一起应用,以便将其应用于所有元素?)

  ask by Vincent Hogendoorn translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...