Skip to content

Commit

Permalink
Merge pull request #3423 from camptocamp/text-position
Browse files Browse the repository at this point in the history
Fix text place when the label and the coords are displayed
  • Loading branch information
sbrunner committed Jan 19, 2018
2 parents a4549fa + 874c77a commit f4e77d7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/featurehelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ ngeo.FeatureHelper.prototype.getPointStyle_ = function(feature) {
})
})
})];
//Label Style
// Label Style
const textLabelValues = [];
if (showMeasure) {
textLabelValues.push(this.getMeasure(feature));
Expand All @@ -262,10 +262,14 @@ ngeo.FeatureHelper.prototype.getPointStyle_ = function(feature) {
if (showLabel || showMeasure) {
// display both label using \n
const textLabelValue = textLabelValues.join('\n');
const font_size = 10;
// https://reeddesign.co.uk/test/points-pixels.html
const point_to_px = 1.3;
styles.push(new ol.style.Style({
text: this.createTextStyle_({
text: textLabelValue,
offsetY: -(size + 10 / 2 + 4)
size: font_size,
offsetY: -(size + (font_size / 2) * textLabelValues.length * point_to_px + 4)
})
}));
}
Expand Down

0 comments on commit f4e77d7

Please sign in to comment.