Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a label bold in open layers 3?

Tags:

openlayers-3

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?

like image 954
Alex Avatar asked Jun 27 '14 19:06

Alex


1 Answers

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
like image 83
Alex Avatar answered Oct 17 '22 15:10

Alex