diff --git a/src/jmap/config/skinCode/bejing_01.js b/src/jmap/config/skinCode/bejing_01.js index 6f190cc1c..951191791 100644 --- a/src/jmap/config/skinCode/bejing_01.js +++ b/src/jmap/config/skinCode/bejing_01.js @@ -457,7 +457,6 @@ class SkinCode extends defaultStyle { haveTextHSDA: true, // 是否需创建textHSDA对象 haveArrowText: true, // 是否需创建arrowText对象 haveTrainBorder: false, // 是否需创建trainBorder对象 - aspectRatio: 7/5, // 字体宽高比例(用以拼接text是计算位置) textOffset: 4, // 字体偏移(用以控制字体据车头的距离) trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸 useSelfFormat: true, // 使用配置项的nameFormat diff --git a/src/jmap/config/skinCode/chengdu_03.js b/src/jmap/config/skinCode/chengdu_03.js index 77bf6c5e6..c795b3cb1 100644 --- a/src/jmap/config/skinCode/chengdu_03.js +++ b/src/jmap/config/skinCode/chengdu_03.js @@ -423,7 +423,6 @@ class SkinCode extends defaultStyle { haveTextHSDA: true, // 是否需创建textHSDA对象 haveArrowText: true, // 是否需创建arrowText对象 haveTrainBorder: false, // 是否需创建trainBorder对象 - aspectRatio: 4/7, // 字体宽高比例(用以拼接text是计算位置) textOffset: 4, // 字体偏移(用以控制字体据车头的距离) trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸 useSelfFormat: true, // 使用配置项的nameFormat diff --git a/src/jmap/config/skinCode/fuzhou_01.js b/src/jmap/config/skinCode/fuzhou_01.js index f5233389e..51ab11820 100644 --- a/src/jmap/config/skinCode/fuzhou_01.js +++ b/src/jmap/config/skinCode/fuzhou_01.js @@ -371,7 +371,6 @@ class SkinCode extends defaultStyle { haveTextHSDA: false, // 是否需创建textHSDA对象 haveArrowText: true, // 是否需创建arrowText对象 haveTrainBorder: false, // 是否需创建trainBorder对象 - aspectRatio: 8/15, // 字体宽高比例(用以拼接text是计算位置) textOffset: 1, // 字体偏移(用以控制字体据车头的距离) trainWidthMoreText: 2 // 计算列车长度时--列车长比text多出尺寸 }, diff --git a/src/jmap/shape/Train/TrainBody.js b/src/jmap/shape/Train/TrainBody.js index 57874c7e1..de2e42324 100644 --- a/src/jmap/shape/Train/TrainBody.js +++ b/src/jmap/shape/Train/TrainBody.js @@ -217,23 +217,23 @@ export default class TrainBody extends Group { formatChangePosition(model, style) { if (this.nameFormat) { const arr = this.nameFormat.split(':'); - let fontNumber = 0; + let widthText = 0; arr.forEach(ele => { if (ele == 'targetCode') { - this.textTrainNumber.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset) ); - fontNumber += (style.Train.trainNumber.targetCodePrefix || '').length; + this.textTrainNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset) ); + widthText += this.textTrainNumber.getBoundingRect().width; this.add(this.textTrainNumber); } else if (ele == 'serviceNumber') { - this.textTrainServer.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset)); - fontNumber += (style.Train.trainServer.serviceNumberPrefix || '').length; + this.textTrainServer.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset)); + widthText += this.textTrainServer.getBoundingRect().width; this.add(this.textTrainServer); } else if (ele == 'tripNumber') { - this.textTrainTarget.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset)); - fontNumber += (style.Train.trainTarget.tripNumberPrefix || '').length; + this.textTrainTarget.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset)); + widthText += this.textTrainTarget.getBoundingRect().width; this.add(this.textTrainTarget); } else if (ele == 'groupNumber') { - this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset)); - fontNumber += (style.Train.trainTargetNumber.groupNumberPrefix || '').length; + this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset)); + widthText += this.textTrainTargetNumber.getBoundingRect().width; this.add(this.textTrainTargetNumber); } });