Goal:
I am trying to display two labels for a line using OpenLayers 6.2 (one above the line, and one below the line) while the decluttering feature is turned on.
Picture of target state with decluttering on.
Problem:
When decluttering is turned off, I can achieve my goal, but when decluttering is turned on it will turn off the text below the line.
Background:
Please refer to the attached CodeSandbox (index.js file) (or the code snippet below) – where I have setup an example of my current javascript– on line 19 and 30 if the numbers are changed to -23 or 24 (or anything closer to the line) respectively, you will note the bottom label will turn off if decluttering is set to true on line 64 https://codesandbox.io/s/line-label-style-7y5ly
feature.setStyle([
new Style({
stroke: new Stroke({
color: "blue",
width: 3
}),
text: new Text({
text: "Text 1 Lorem Ipsum",
placement: "line",
textBaseline: "middle",
offsetY: -24,
padding: [-10, -10, -10, -10],
stroke: new Stroke({ color: "red" }),
backgroundStroke: new Stroke({ color: "red" })
})
}),
new Style({
text: new Text({
text: "Text 2 Lorem Ipsum",
placement: "line",
textBaseline: "middle",
offsetY: 25,
padding: [-10, -10, -10, -10],
stroke: new Stroke({ color: "blue" }),
backgroundStroke: new Stroke({ color: "blue" })
})
})
])