| | |
| | | }, |
| | | methods: { |
| | | createMap() { |
| | | this.pixiApp = new PIXI.Application({ backgroundColor: 0xF5F7F9FF }); |
| | | this.pixiApp = new PIXI.Application({ backgroundColor: 0xF5F7F9FF, antialias: true }); |
| | | this.$refs.pixiView.appendChild(this.pixiApp.view); |
| | | this.pixiApp.view.style.width = '100%'; |
| | | this.pixiApp.view.style.height = '100%'; |
| | |
| | | const newPosX = sx - worldX * newZoom; |
| | | const newPosY = sy - worldY * newZoom; |
| | | this.pixiApp.stage.setTransform(newPosX, newPosY, newZoom, newZoom, 0, 0, 0, 0, 0); |
| | | this.adjustLabelScale(); |
| | | }); |
| | | //*******************缩放画布******************* |
| | | |
| | |
| | | const posX = (vw - contentW * scale) / 2 - minX * scale; |
| | | const posY = (vh - contentH * scale) / 2 - minY * scale; |
| | | this.pixiApp.stage.setTransform(posX, posY, scale, scale, 0, 0, 0, 0, 0); |
| | | this.adjustLabelScale(); |
| | | this.map = map; |
| | | }, |
| | | initWidth(map) { |
| | |
| | | } |
| | | } |
| | | } |
| | | this.adjustLabelScale(); |
| | | } |
| | | }); |
| | | }, |
| | |
| | | } |
| | | } |
| | | } |
| | | this.adjustLabelScale(); |
| | | } |
| | | }); |
| | | }, |
| | |
| | | getTrackSiteNo(obj) { |
| | | if (this.isJson(obj)) { let data = JSON.parse(obj); if (data.trackSiteNo == null || data.trackSiteNo == undefined) { return -1; } return data.trackSiteNo; } else { return -1; } |
| | | }, |
| | | adjustLabelScale() { |
| | | const s = this.pixiApp && this.pixiApp.stage ? (this.pixiApp.stage.scale.x || 1) : 1; |
| | | const minPx = 14; |
| | | this.pixiStaMap && this.pixiStaMap.forEach((sprite) => { |
| | | const textObj = sprite && sprite.textObj; |
| | | if (!textObj) { return; } |
| | | const base = (textObj.style && textObj.style.fontSize) ? textObj.style.fontSize : 10; |
| | | let scale = minPx / (base * s); |
| | | if (!isFinite(scale)) { scale = 1; } |
| | | scale = Math.max(0.8, Math.min(scale, 3)); |
| | | textObj.scale.set(scale); |
| | | textObj.position.set(sprite.width / 2, sprite.height / 2); |
| | | }); |
| | | this.pixiCrnMap && this.pixiCrnMap.forEach((sprite) => { |
| | | const textObj = sprite && sprite.textObj; |
| | | if (!textObj) { return; } |
| | | const base = (textObj.style && textObj.style.fontSize) ? textObj.style.fontSize : 12; |
| | | let scale = minPx / (base * s); |
| | | if (!isFinite(scale)) { scale = 1; } |
| | | scale = Math.max(0.8, Math.min(scale, 3)); |
| | | textObj.scale.set(scale); |
| | | textObj.position.set(sprite.width / 2, sprite.height / 2); |
| | | }); |
| | | this.pixiRgvMap && this.pixiRgvMap.forEach((sprite) => { |
| | | const textObj = sprite && sprite.textObj; |
| | | if (!textObj) { return; } |
| | | const base = (textObj.style && textObj.style.fontSize) ? textObj.style.fontSize : 12; |
| | | let scale = minPx / (base * s); |
| | | if (!isFinite(scale)) { scale = 1; } |
| | | scale = Math.max(0.8, Math.min(scale, 3)); |
| | | textObj.scale.set(scale); |
| | | textObj.position.set(sprite.width / 2, sprite.height / 2); |
| | | }); |
| | | } |
| | | } |
| | | }); |