1

As far as I know with CSS knowledge, textAlign:left means the text should be stick left of the element. W3School textalign

but in Openlayers, it looks working opposite.
Openlayers vector label example.
click the link above, and choose left from align select box, then press refresh then the texts moves to right side like textAlign:right.

How does textAlign work in OpenLayers?

3

Actually it is not opposite. TextAlignworks relative to something. In the case of the W3Schools example, in the case of left-align, it aligns the left hand end of the text (its start) to the left-hand side of the page. For right-align, it aligns the right-hand side of the text (its end) to the right hand side of the page.

With OL, the text is being aligned to a point location and not a page. So left align aligns the left-hand-end of the text string (ie the start) to the point (or centroid), which is why it sticks out to the right of the point. This is why, with a point location the start and end alignment options effectively work the same as left and right respectively.

  • Thanks! very clear. so is not the same concept as css textAlign. for start and end is reasonable but it feels they should swap for left and right – Chase Choi Jun 13 '17 at 9:39

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.