From aa655af742c754a3ec9673164bed9ddd35b51c70 Mon Sep 17 00:00:00 2001 From: hpinkos Date: Tue, 10 Jul 2018 11:32:05 -0400 Subject: [PATCH] fix label translate --- Source/Scene/LabelCollection.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Scene/LabelCollection.js b/Source/Scene/LabelCollection.js index ffeafea9a3e1..2c2ea2c277bc 100644 --- a/Source/Scene/LabelCollection.js +++ b/Source/Scene/LabelCollection.js @@ -306,7 +306,7 @@ define([ var maxGlyphDescent = Number.NEGATIVE_INFINITY; var maxGlyphY = 0; var numberOfLines = 1; - var glyphIndex = 0; + var glyphIndex; var glyphLength = glyphs.length; var backgroundBillboard = label._backgroundBillboard; @@ -387,7 +387,7 @@ define([ glyph.billboard._labelHorizontalOrigin = horizontalOrigin; } - //Compute the next x offset taking into acocunt the kerning performed + //Compute the next x offset taking into account the kerning performed //on both the current letter as well as the next letter to be drawn //as well as any applied scale. if (glyphIndex < glyphLength - 1) { @@ -422,13 +422,15 @@ define([ backgroundBillboard.width = totalLineWidth; backgroundBillboard.height = totalLineHeight; backgroundBillboard._setTranslate(glyphPixelOffset); + backgroundBillboard._labelTranslate = Cartesian2.clone(glyphPixelOffset, backgroundBillboard._labelTranslate); } if (label.heightReference === HeightReference.CLAMP_TO_GROUND) { for (glyphIndex = 0; glyphIndex < glyphLength; ++glyphIndex) { - if (text.charAt(glyphIndex) !== '\n') { - glyph = glyphs[glyphIndex]; - Cartesian2.clone(glyphPixelOffset, glyph._labelTranslate); + glyph = glyphs[glyphIndex]; + var billboard = glyph.billboard; + if (defined(billboard)) { + billboard._labelTranslate = Cartesian2.clone(glyphPixelOffset, billboard._labelTranslate); } } }