xjxcmap.js 1.68 KB
Newer Older
纪泽龙's avatar
纪泽龙 committed
1 2 3
/*
 * @Author: your name
 * @Date: 2022-04-13 09:42:29
纪泽龙's avatar
纪泽龙 committed
4
 * @LastEditTime: 2022-04-14 16:22:10
纪泽龙's avatar
纪泽龙 committed
5 6 7 8
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /gassafety-progress/gassafetyprogress-web/src/utils/mapClass/xjxjmap.js
 */
纪泽龙's avatar
纪泽龙 committed
9
import { EditorMap } from "./map";
纪泽龙's avatar
纪泽龙 committed
10
export class XjxcMap extends EditorMap {
纪泽龙's avatar
纪泽龙 committed
11 12 13 14 15
  iconType1 = 98;
  iconType2 = 99;
  iconType3 = 0;
  constructor(contaienr, config = {}, vue) {
    super(contaienr, (config = {}), vue);
纪泽龙's avatar
纪泽龙 committed
16
  }
纪泽龙's avatar
纪泽龙 committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
  create(data, componentDevice, componentPipe) {
    const path = eval(data.path);
    if (path.length < 1) return;
    console.log(path);
    // 开头
    const deviceData1 = {
      longitude: path[0][0],
      latitude: path[0][1],
      iconType: this.iconType1,
    };
    // 结尾
    const deviceData2 = {
      longitude: path[path.length - 1][0],
      latitude: path[path.length - 1][1],
      iconType: this.iconType2,
    };
    // 路线
    const pipeData = {
      title:data.title ||"中燃科技",
      path,
      iconType: this.iconType3,
      pipePressure: 4,
      strokeWeight: 2,
    };
纪泽龙's avatar
纪泽龙 committed
41

纪泽龙's avatar
纪泽龙 committed
42 43 44 45 46
    this.addPipeLine(pipeData, componentPipe);
    this.addDevice(deviceData1, componentDevice);
    this.addDevice(deviceData2, componentDevice);
    // // 前取整
    const num = path.length >> 1;
纪泽龙's avatar
纪泽龙 committed
47

纪泽龙's avatar
纪泽龙 committed
48 49 50 51 52 53 54 55 56 57 58 59 60
    this.map.panTo(path[num]);
  }
  remove() {
    if (this.allDevice[98]?.length > 0) {
      this.map.remove(this.allDevice[98][0]);
      this.allDevice[98] = [];
      this.map.remove(this.allDevice[99][0]);
      this.allDevice[99] = [];
      this.map.remove(this.pipeArr[0][0]);
      this.pipeArr[0] = [];
    }
  }
}