75 lines
1.7 KiB
JavaScript
75 lines
1.7 KiB
JavaScript
|
/*
|
||
|
* 车站
|
||
|
*/
|
||
|
import Group from 'zrender/src/container/Group';
|
||
|
import ETextName from '../element/ETextName'; // 名称文字 (共有)
|
||
|
|
||
|
export default class Station extends Group {
|
||
|
constructor(model, style) {
|
||
|
super();
|
||
|
this._code = model.code;
|
||
|
this._type = model._type;
|
||
|
this.zlevel = model.zlevel;
|
||
|
this.z = 40;
|
||
|
this.model = model;
|
||
|
this.style = style;
|
||
|
this.create();
|
||
|
this.setState(model);
|
||
|
}
|
||
|
|
||
|
create() {
|
||
|
const model = this.model;
|
||
|
const style = this.style;
|
||
|
|
||
|
if (model.visible) {
|
||
|
// 公里标名称是否显示
|
||
|
this.stationText = new ETextName({
|
||
|
zlevel: this.zlevel,
|
||
|
z: this.z,
|
||
|
position: [0, 0],
|
||
|
x: model.position.x,
|
||
|
y: model.position.y,
|
||
|
fontWeight: model.fontWeight,
|
||
|
fontSize: model.nameFont || 18,
|
||
|
fontFamily: style.fontFamily,
|
||
|
text: model.name,
|
||
|
textAlign: 'middle',
|
||
|
textVerticalAlign: 'top',
|
||
|
textFill: model.nameFontColor
|
||
|
});
|
||
|
this.add(this.stationText);
|
||
|
const path = window.location.href;
|
||
|
if (style.Station.kmPostShow || path.includes('/map/draw')) {
|
||
|
// 公里标是否显示
|
||
|
let direction = 1;
|
||
|
if (this.style.Station.kilometerPosition == 'up') {
|
||
|
direction = -1;
|
||
|
}
|
||
|
this.mileageText = new ETextName({
|
||
|
zlevel: this.zlevel,
|
||
|
z: this.z,
|
||
|
position: [0, 0],
|
||
|
x: model.position.x,
|
||
|
y: model.position.y + ((parseInt(model.nameFont) + 2) * direction),
|
||
|
fontWeight: model.fontWeight,
|
||
|
fontSize: model.kmPostFont || 18,
|
||
|
fontFamily: style.fontFamily,
|
||
|
text: model.kmPost,
|
||
|
textAlign: 'middle',
|
||
|
textVerticalAlign: 'top',
|
||
|
textFill: model.kmPostFontColor
|
||
|
});
|
||
|
this.add(this.mileageText);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// eslint-disable-next-line no-unused-vars
|
||
|
setState(model) {
|
||
|
}
|
||
|
|
||
|
getShapeTipPoint() {
|
||
|
return null;
|
||
|
}
|
||
|
}
|