6

I'm labelling markers in a vector layer.

TextOptions of a ol.style.Text object include arrording to the docs (http://ol3js.org/en/v3.0.0-beta.1/apidoc/ol.style.html#TextOptions) no option to change font-weight.

In ol2 I used:

fontWeight: "bold"

This doesn't seem to work in ol3.

How can this be done?

Hunsu
  • 3,281
  • 7
  • 29
  • 64
Alex
  • 2,117
  • 5
  • 28
  • 36

1 Answers1

15

I found a solution by looking at the example here: https://openlayers.org/en/master/examples/vector-labels.html:

font = weight + ' ' + size + ' ' + font

for instance:

font: 'bold 11px Arial, Verdana, Helvetica, sans-serif'

I don't think there is an explanation in the official docs yet - it only says:

  • Type: string
  • Description: Font
Icarus
  • 1,627
  • 7
  • 18
  • 32
Alex
  • 2,117
  • 5
  • 28
  • 36
  • The docs are always behind the source code/examples in OpenLayers, which I think is reasonable, given how good the examples and how readable the source. – John Powell Jul 16 '14 at 08:05
  • 2
    Useful answer. Of course the examples are good, but it can take times to find exactly what you want ! – Pierre Henry Aug 13 '14 at 12:57