Skip to content

Commit

Permalink
Set correct print labelAlign
Browse files Browse the repository at this point in the history
Default values in OpenLayers are 'center' and 'middle'.
  • Loading branch information
fredj committed Oct 10, 2017
1 parent 2f93fde commit 9f80827
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/services/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,10 +747,22 @@ ngeo.Print.prototype.encodeTextStyle_ = function(symbolizers, textStyle) {
const label = textStyle.getText();
if (label !== undefined) {
symbolizer.label = label;
symbolizer.labelAlign = 'cm';

const xAlign = textStyle.getTextAlign();
// 'left', 'right', 'center', 'end' or 'start'.
if (xAlign === 'left' || xAlign === 'start') {
symbolizer.labelAlign[0] = 'l';
} else if (xAlign === 'right' || xAlign === 'end') {
symbolizer.labelAlign[0] = 'r';
}

const labelAlign = textStyle.getTextAlign();
if (labelAlign !== undefined) {
symbolizer.labelAlign = labelAlign;
const yAlign = textStyle.getTextBaseline();
// 'bottom', 'top', 'middle', 'alphabetic', 'hanging' or 'ideographic'
if (yAlign === 'bottom') {
symbolizer.labelAlign[1] = 'l';
} else if (yAlign === 'top') {
symbolizer.labelAlign[1] = 't';
}

const labelRotation = textStyle.getRotation();
Expand Down

0 comments on commit 9f80827

Please sign in to comment.