xjxcmap.js 1.68 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
/*
 * @Author: your name
 * @Date: 2022-04-13 09:42:29
 * @LastEditTime: 2022-04-14 16:22:10
 * @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
 */
import { EditorMap } from "./map";
export class XjxcMap extends EditorMap {
  iconType1 = 98;
  iconType2 = 99;
  iconType3 = 0;
  constructor(contaienr, config = {}, vue) {
    super(contaienr, (config = {}), vue);
  }
  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,
    };

    this.addPipeLine(pipeData, componentPipe);
    this.addDevice(deviceData1, componentDevice);
    this.addDevice(deviceData2, componentDevice);
    // // 前取整
    const num = path.length >> 1;

    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] = [];
    }
  }
}