1

I have a text inside a style which fits inside a vector polygon.

On small polygons the text disappears (map is zoomed in max) so I am trying to set exceed len to true based on this example.

How can I use this within my style?

let style_selected = function (feature, resolution) {
let getParcel2 = feature.get("parcel_nbr")+"";
return new ol.style.Style({
  fill: new ol.style.Fill({
  color: '#5fba6a38'
}),
 stroke: new ol.style.Stroke({
    color: 'red',
    width: 3
  }),
  text: new ol.style.Text({
    text: getParcel2,
    font: '4em Calibri,sans-serif',
    fill: new ol.style.Fill({
    color: 'white'
    }),
    stroke: new ol.style.Stroke({
      color: 'green',
      width: 5
    })
  })
});
}
2

You have to set ol.style.Text option overflow to true to allow text to exceed the width of the polygon:

text: new ol.style.Text({
  text: getParcel2,
  font: '4em Calibri,sans-serif',
  fill: new ol.style.Fill({
    color: 'white'
  }),
  stroke: new ol.style.Stroke({
    color: 'green',
    width: 5
  }),
  overflow: true
})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.