/* * 车站 */ import Group from 'zrender/src/container/Group'; import ETextName from '../element/ETextName'; // import EHighlight from '../element/EHighlight'; // 名称文字 (共有) import EControl from '../element/EControl'; 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.createTurnBack(); // 创建按图折返 this.setState(model); // this.checkIsDrawMap(); } 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); } } } createTurnBack() { // 创建按图折返 const model = this.model; const style = this.style; if (model.visible && model.isCreateTurnBack) { this.turnBack = new EControl({ zlevel: this.zlevel, z: this.z, arc: { shape: { cx: model.pullBackModel.position.x, cy: model.pullBackModel.position.y, r: style.Station.lamp.radiusR }, lineWidth: 0, fill: style.Station.lamp.controlColor }, text: { position: [0, 0], x: model.pullBackModel.position.x, y: model.pullBackModel.position.y + style.Station.lamp.radiusR + style.Station.text.distance, fontWeight: style.Station.text.fontWeight, fontSize: style.Station.text.fontSize, fontFamily: style.fontFamily, text: '按图折返', textFill: '#fff', textAlign: 'middle', textVerticalAlign: 'top' }, style: this.style }); this.add(this.turnBack); } } // eslint-disable-next-line no-unused-vars setState(model) { } getShapeTipPoint() { return null; } drawSelected(selected) { this.highlight && this.highlight.drawSelected(selected); } // checkIsDrawMap() { // const path = window.location.href; // if (path.includes('/map/draw')) { // this.highlight = new EHighlight(this); // this.add(this.highlight); // this.on('mouseout', () => { this.highlight.mouseout(); }); // this.on('mouseover', () => { this.highlight.mouseover(); }); // } // } }