gaodeMap.js 29.2 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1
import createPop from "./createPop";
纪泽龙's avatar
纪泽龙 committed
2 3 4
import regulatorBox from "../components/PopWindow/regulatorBox.vue";
import valveWell from "../components/PopWindow/valveWell.vue";
import flowMeter from "../components/PopWindow/flowMeter.vue";
纪泽龙's avatar
纪泽龙 committed
5
import pressureGage from "../components/PopWindow/pressureGage.vue";
纪泽龙's avatar
纪泽龙 committed
6 7
import pipelineView from "../components/PopWindow/pipelineView.vue";
import lineInfoWindow from "../components/PopWindow/lineInfoWindow.vue";
8
import { delDeviceInfo, updateDeviceInfo } from "@/api/device/deviceInfo";
耿迪迪's avatar
耿迪迪 committed
9
import markerInfoWindow from "../components/PopWindow/markerInfoWindow.vue";
纪泽龙's avatar
纪泽龙 committed
10
import { getArray } from "@/utils/gassafety.js";
11
import { delPipe, updatePipe } from "@/api/device/pipe.js";
纪泽龙's avatar
纪泽龙 committed
12
import vue from "../main";
耿迪迪's avatar
耿迪迪 committed
13
let defaultCenter = "石家庄";
耿迪迪's avatar
耿迪迪 committed
14
export let map;
15
export const DEVICE_TYPE = {
纪泽龙's avatar
纪泽龙 committed
16 17 18 19
  PIPEPLINE: "1",
  REGEULATORBOX: "2",
  VALUEWELL: "3",
  FLOWMETER: "4",
yaqizhang's avatar
yaqizhang committed
20
  DUTYPERSON: "5",
21
  WORKORDER: "6",
22 23
  PRESSUREGAGE: "7",
  INSPECTOR: "8"
纪泽龙's avatar
纪泽龙 committed
24
};
耿迪迪's avatar
耿迪迪 committed
25
class gaodeMap {
纪泽龙's avatar
纪泽龙 committed
26 27 28 29 30 31
  // 所有线的数组
  polyLines = [];
  // 是否开启新增
  lineType = 0;
  // 创建一个新的lineObj
  newLineObj = null;
纪泽龙's avatar
纪泽龙 committed
32 33
  // onceFlag=false;
  lineFlag = false;
纪泽龙's avatar
纪泽龙 committed
34
  mouseTool = null;
纪泽龙's avatar
纪泽龙 committed
35
  myMap = null;
纪泽龙's avatar
纪泽龙 committed
36
  showInfoWindow = null;
37
  view = null;
纪泽龙's avatar
纪泽龙 committed
38

耿迪迪's avatar
耿迪迪 committed
39 40
  //构造函数中设置中央点默认值
  constructor(center) {
41
    this.markers = [];
纪泽龙's avatar
纪泽龙 committed
42 43
    this.center = center ? center : defaultCenter;
    map = new AMap.Map("container", {
耿迪迪's avatar
耿迪迪 committed
44 45 46 47
      //mask: addMask(result.districtList[0].boundaries),
      center: [114.72995, 38.37417],
      // resizeEnable: true,
      disableSocket: true,
纪泽龙's avatar
纪泽龙 committed
48
      viewMode: "3D",
耿迪迪's avatar
耿迪迪 committed
49 50 51
      showLabel: true,
      // labelzIndex: 110,
      pitch: 8,
纪泽龙's avatar
纪泽龙 committed
52
      zoom: 9
耿迪迪's avatar
耿迪迪 committed
53 54 55
      //mapStyle: 'amap://styles/darkblue',
      // mapStyle: 'amap://styles/3b679a15f448a4740ba2ff7524e1a4ae',
    });
纪泽龙's avatar
纪泽龙 committed
56
    this.myMap = map;
纪泽龙's avatar
纪泽龙 committed
57

纪泽龙's avatar
纪泽龙 committed
58
    this.myMap.on("click", e => {
纪泽龙's avatar
纪泽龙 committed
59 60 61
      // if (this.lineType !=1 || this.lineFlag) return;
      if (this.lineType != 1 || this.lineFlag) return;

纪泽龙's avatar
纪泽龙 committed
62
      // 除了这里,还要利用vue页面的window事件辅助,当组件出来的时候,就得利用window事件
纪泽龙's avatar
纪泽龙 committed
63 64 65 66 67 68 69 70 71
      if (this.newLineObj) {
        vue
          .$confirm("是否重新画管道")
          .then(() => {
            this.newLineObj.polyEditor.close();
            map.remove(this.newLineObj);
            this.newLineObj = null;
            this.lineFlag = false;
            this.createNewLine();
纪泽龙's avatar
纪泽龙 committed
72

纪泽龙's avatar
纪泽龙 committed
73 74 75
            console.log("map点击事件新建");
          })
          .catch(() => {});
纪泽龙's avatar
纪泽龙 committed
76
      }
纪泽龙's avatar
纪泽龙 committed
77
      // console.log("抬起来了");
纪泽龙's avatar
纪泽龙 committed
78
    });
纪泽龙's avatar
纪泽龙 committed
79

80 81 82 83 84 85 86 87 88 89
    // 地图开始平移删除infowindow
    this.myMap.on("movestart", () => {
      // console.log("地图平移");
      this.closeInfoWindow();
    });
    // 地图开始缩放删除infowindow
    this.myMap.on("zoomstart", () => {
      // console.log("缩放开始")
      this.closeInfoWindow();
    });
90 91 92 93
    this.myMap.on("moveend", () => {
      // console.log("缩放开始")
      if (!this.onceFlag) {
        this.onceFlag = true;
纪泽龙's avatar
纪泽龙 committed
94 95 96 97 98
        if (this.view) {
          this.view.backFlag = false;
          // 让抽屉不在隐身
          this.view.drawerOpacity = true;
        }
99 100 101
      }
    });

耿迪迪's avatar
耿迪迪 committed
102 103 104 105 106 107 108
    this.districtBoundaries();
  }

  /**
   * 获取map
   * @returns {AMap.Map}
   */
纪泽龙's avatar
纪泽龙 committed
109
  get getMap() {
耿迪迪's avatar
耿迪迪 committed
110 111 112 113 114 115 116
    return this.map;
  }

  /**
   * 重新设置中央点
   * @param value
   */
纪泽龙's avatar
纪泽龙 committed
117
  set setCenter(value) {
耿迪迪's avatar
耿迪迪 committed
118 119 120 121
    this.center = value;
    this.districtBoundaries();
  }

纪泽龙's avatar
纪泽龙 committed
122
  resetMapCenter(value) {
yaqizhang's avatar
yaqizhang committed
123 124 125
    map.setCenter(value);
  }

耿迪迪's avatar
耿迪迪 committed
126 127 128
  /**
   * 设置城市边界
   */
纪泽龙's avatar
纪泽龙 committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156

  districtBoundaries() {
    let that = this;
    let opts = {
      subdistrict: 0,
      extensions: "all",
      level: "city"
    };
    let district = new AMap.DistrictSearch(opts);
    district.search(that.center, function(status, result) {
      if (status == "complete") {
        let defaultCenter = [];
        defaultCenter.push(result.districtList[0].center.lng);
        defaultCenter.push(result.districtList[0].center.lat);
        map.setCenter(defaultCenter);
        let bounds = result.districtList[0].boundaries;
        for (let i = 0; i < bounds.length; i += 1) {
          new AMap.Polyline({
            path: bounds[i],
            strokeColor: "#0088ff",
            strokeWeight: 5,
            strokeOpacity: 7,
            map: map
          });
        }
      }
    });
  }
耿迪迪's avatar
耿迪迪 committed
157 158 159

  /**
   * 添加Market
160
   * @param markerType
耿迪迪's avatar
耿迪迪 committed
161 162
   * @param lnglats
   */
耿迪迪's avatar
耿迪迪 committed
163
  addMarker(markerType, data) {
164 165
    let that = this;
    that.markerType = markerType;
纪泽龙's avatar
纪泽龙 committed
166 167
    let infoWindow = new AMap.InfoWindow({
      isCustom: true,
168
      offset: new AMap.Pixel(24, -38),
纪泽龙's avatar
纪泽龙 committed
169 170
      anchor: "left-top"
    });
171
    infoWindow.on("mouseover", function() {
172 173 174 175
      let options = map.getStatus();
      options.scrollWheel = false;
      map.setStatus(options);
    });
176
    infoWindow.on("mouseout", function() {
177 178 179 180
      let options = map.getStatus();
      options.scrollWheel = true;
      map.setStatus(options);
    });
耿迪迪's avatar
耿迪迪 committed
181
    let marker = new AMap.Marker({
纪泽龙's avatar
纪泽龙 committed
182
      position: [data.longitude, data.latitude],
耿迪迪's avatar
耿迪迪 committed
183
      map: map,
184
      offset: new AMap.Pixel(0, 5)
耿迪迪's avatar
耿迪迪 committed
185 186
    });
    this.setMarkerIcon(marker);
187 188 189 190
    if (
      DEVICE_TYPE.WORKORDER != markerType &&
      DEVICE_TYPE.INSPECTOR != markerType
    ) {
耿迪迪's avatar
耿迪迪 committed
191
      marker.content = this.getMarketContent(data);
yaqizhang's avatar
yaqizhang committed
192 193 194 195
      marker.on("mouseover", infoOpen);
      marker.on("mouseout", infoClose);
      marker.setExtData(data);
      that.deviceType = markerType;
196
      let editWindow = that.createInfowindow("编辑");
纪泽龙's avatar
纪泽龙 committed
197 198 199 200
      editWindow.fileArr =
        data.iconUrl != "" && data.iconUrl != undefined
          ? [{ url: data.iconUrl }]
          : [];
201 202 203
      editWindow.obj = marker;
      editWindow.gaoMap = that;
      editWindow.map = map;
yaqizhang's avatar
yaqizhang committed
204 205 206 207 208
      marker.on("click", function(e) {
        if ("edit" == that.mapOperateType) {
          editWindow.form = e.target.getExtData();
          editWindow.show();
        } else if ("delete" == that.mapOperateType) {
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
          let diviceType = {
            "2": "调压箱",
            "3": "阀门井",
            "4": "流量计",
            "7": "压力表"
          };
          vue
            .$confirm(
              '是否删除名称为"' +
                e.target.getExtData().deviceName +
                '"的' +
                diviceType[markerType] +
                " ?",
              "提示",
              {
                type: "warning"
                // center: true
              }
            )
            .then(() => {
              // that.deleteMarker(markerType, data.deviceId);
              that.deleteMarker(markerType, data).then(res => {
                if (res.code == 200) {
                  map.remove(marker);
                  // 数组里也删了
                  const ind = that.markers.indexOf(marker);
                  if (ind >= 0) {
                    that.markers.splice(ind, 1);
237
                    console.log(that.markers);
238 239 240 241 242
                  }
                }
              });
            })
            .catch(() => {
243 244 245 246 247 248 249
              vue.$message({
                type: "info",
                // center:true,
                offset: 100,
                message: "已取消删除"
              });
            });
250
        } /*else {
251
          //map.setZoomAndCenter(13, e.target.getPosition());
yaqizhang's avatar
yaqizhang committed
252 253
          let infoWindow = new AMap.InfoWindow({
            isCustom: true,
254
            offset: new AMap.Pixel(24, -38),
yaqizhang's avatar
yaqizhang committed
255 256 257 258
            anchor: "left-top"
          });
          infoWindow.setContent(e.target.content);
          infoWindow.open(map, e.target.getPosition());
259
        }*/
yaqizhang's avatar
yaqizhang committed
260 261 262 263 264
      });
      marker.on("dragend", function(e) {
        editWindow.form.longitude = e.lnglat.lng;
        editWindow.form.latitude = e.lnglat.lat;
      });
265 266
    } else {
      marker.on("mouseover", function() {
yaqizhang's avatar
yaqizhang committed
267
        marker.setLabel({
268 269 270
          offset: new AMap.Pixel(0, -10), //设置文本标注偏移量
          content: "<div class='info'>" + data.deviceName + "</div>", //设置文本标注内容
          direction: "top" //设置文本标注方位
yaqizhang's avatar
yaqizhang committed
271 272
        });
      });
273
      marker.on("mouseout", function() {
yaqizhang's avatar
yaqizhang committed
274 275
        marker.setLabel({
          content: null
276
        });
yaqizhang's avatar
yaqizhang committed
277
      });
yaqizhang's avatar
yaqizhang committed
278
    }
耿迪迪's avatar
耿迪迪 committed
279

耿迪迪's avatar
耿迪迪 committed
280 281 282
    this.markers.push(marker);
    map.setZoom("11");
    //map.setFitView();
耿迪迪's avatar
耿迪迪 committed
283 284

    function infoClose(e) {
285 286 287 288
      let options = map.getStatus();
      options.scrollWheel = true;
      map.setStatus(options);
      //infoWindow.close(map, e.target.getPosition());
耿迪迪's avatar
耿迪迪 committed
289 290 291
    }

    function infoOpen(e) {
292 293 294
      let options = map.getStatus();
      options.scrollWheel = false;
      map.setStatus(options);
耿迪迪's avatar
耿迪迪 committed
295 296
      infoWindow.setContent(e.target.content);
      infoWindow.open(map, e.target.getPosition());
纪泽龙's avatar
纪泽龙 committed
297
      that.markerInfoWindow = infoWindow;
耿迪迪's avatar
耿迪迪 committed
298
    }
299 300
  }

耿迪迪's avatar
耿迪迪 committed
301 302 303
  /**
   * marker添加拖拽事件
   */
纪泽龙's avatar
纪泽龙 committed
304 305
  addMarkerDragg() {
    for (var i = 0; i < this.markers.length; i++) {
耿迪迪's avatar
耿迪迪 committed
306 307 308 309 310 311 312
      this.markers[i].setDraggable(true);
    }
  }

  /**
   * marker移除拖拽事件
   */
纪泽龙's avatar
纪泽龙 committed
313 314
  removeMarkerDragg() {
    for (var i = 0; i < this.markers.length; i++) {
耿迪迪's avatar
耿迪迪 committed
315 316 317 318
      this.markers[i].setDraggable(false);
    }
  }

纪泽龙's avatar
纪泽龙 committed
319 320 321 322 323 324
  /**
   * 添加marker信息
   * @param data
   * @returns {string}
   */
  getMarketContent(data) {
耿迪迪's avatar
耿迪迪 committed
325 326
    switch (this.markerType) {
      case DEVICE_TYPE.REGEULATORBOX: {
纪泽龙's avatar
纪泽龙 committed
327
        const dom = createPop(markerInfoWindow, {
耿迪迪's avatar
耿迪迪 committed
328
          title: "调压箱",
耿迪迪's avatar
耿迪迪 committed
329
          data: data,
纪泽龙's avatar
纪泽龙 committed
330
          map: map
耿迪迪's avatar
耿迪迪 committed
331 332 333
        });
        const html = dom.$el;
        dom.remove();
耿迪迪's avatar
耿迪迪 committed
334 335 336
        return html;
      }
      case DEVICE_TYPE.VALUEWELL: {
纪泽龙's avatar
纪泽龙 committed
337
        const dom = createPop(markerInfoWindow, {
耿迪迪's avatar
耿迪迪 committed
338
          title: "阀门井",
耿迪迪's avatar
耿迪迪 committed
339
          data: data,
纪泽龙's avatar
纪泽龙 committed
340
          map: map
耿迪迪's avatar
耿迪迪 committed
341 342 343
        });
        const html = dom.$el;
        dom.remove();
耿迪迪's avatar
耿迪迪 committed
344 345 346
        return html;
      }
      case DEVICE_TYPE.FLOWMETER: {
纪泽龙's avatar
纪泽龙 committed
347
        const dom = createPop(markerInfoWindow, {
耿迪迪's avatar
耿迪迪 committed
348
          title: "流量计",
耿迪迪's avatar
耿迪迪 committed
349
          data: data,
纪泽龙's avatar
纪泽龙 committed
350
          map: map
耿迪迪's avatar
耿迪迪 committed
351 352 353
        });
        const html = dom.$el;
        dom.remove();
耿迪迪's avatar
耿迪迪 committed
354 355
        return html;
      }
356
      case DEVICE_TYPE.PRESSUREGAGE: {
纪泽龙's avatar
纪泽龙 committed
357
        const dom = createPop(markerInfoWindow, {
358 359
          title: "压力表",
          data: data,
纪泽龙's avatar
纪泽龙 committed
360
          map: map
361 362 363 364 365
        });
        const html = dom.$el;
        dom.remove();
        return html;
      }
耿迪迪's avatar
耿迪迪 committed
366 367 368
    }
  }

耿迪迪's avatar
耿迪迪 committed
369 370 371 372 373
  /**
   * 删除marker
   * @param delType
   * @param deviceId
   */
374
  deleteMarker(delType, deviceData) {
纪泽龙's avatar
纪泽龙 committed
375 376 377 378 379 380
    if (
      DEVICE_TYPE.REGEULATORBOX == delType ||
      DEVICE_TYPE.VALUEWELL == delType ||
      DEVICE_TYPE.FLOWMETER == delType ||
      DEVICE_TYPE.PRESSUREGAGE == delType
    ) {
381 382 383 384
      // delDeviceInfo(deviceId);
      const upDataObj = { ...deviceData };
      upDataObj.isDel = 1;
      return updateDeviceInfo(upDataObj);
耿迪迪's avatar
耿迪迪 committed
385 386 387
    }
  }

耿迪迪's avatar
耿迪迪 committed
388 389 390 391
  /**
   * 设置设备图标
   * @param marker
   */
纪泽龙's avatar
纪泽龙 committed
392
  setMarkerIcon(marker) {
纪泽龙's avatar
纪泽龙 committed
393 394
    switch (this.markerType) {
      case DEVICE_TYPE.REGEULATORBOX: {
耿迪迪's avatar
耿迪迪 committed
395 396
        let icon = new AMap.Icon({
          //size: new AMap.Size(51, 23),
纪泽龙's avatar
纪泽龙 committed
397
          image: require("../assets/images/tiaoyaxiang.png")
耿迪迪's avatar
耿迪迪 committed
398 399 400
        });
        marker.setIcon(icon);
        break;
401
      }
纪泽龙's avatar
纪泽龙 committed
402
      case DEVICE_TYPE.VALUEWELL: {
耿迪迪's avatar
耿迪迪 committed
403 404
        let icon = new AMap.Icon({
          //size: new AMap.Size(51, 23),
纪泽龙's avatar
纪泽龙 committed
405
          image: require("../assets/images/famenjing.png")
耿迪迪's avatar
耿迪迪 committed
406 407 408
        });
        marker.setIcon(icon);
        break;
409
      }
纪泽龙's avatar
纪泽龙 committed
410
      case DEVICE_TYPE.FLOWMETER: {
耿迪迪's avatar
耿迪迪 committed
411 412
        let icon = new AMap.Icon({
          //size: new AMap.Size(51, 23),
纪泽龙's avatar
纪泽龙 committed
413
          image: require("../assets/images/liuliangji.png")
耿迪迪's avatar
耿迪迪 committed
414 415 416
        });
        marker.setIcon(icon);
        break;
417
      }
纪泽龙's avatar
纪泽龙 committed
418
      case DEVICE_TYPE.DUTYPERSON: {
耿迪迪's avatar
耿迪迪 committed
419 420
        let icon = new AMap.Icon({
          //size: new AMap.Size(51, 23),
421
          image: require("../assets/images/zhibanrenyuan.png")
耿迪迪's avatar
耿迪迪 committed
422 423 424
        });
        marker.setIcon(icon);
        break;
425
      }
yaqizhang's avatar
yaqizhang committed
426 427 428
      case DEVICE_TYPE.WORKORDER: {
        let icon = new AMap.Icon({
          //size: new AMap.Size(51, 23),
429
          image: require("../assets/images/zhibanrenyuan.png")
yaqizhang's avatar
yaqizhang committed
430 431 432 433
        });
        marker.setIcon(icon);
        break;
      }
434 435 436
      case DEVICE_TYPE.PRESSUREGAGE: {
        let icon = new AMap.Icon({
          //size: new AMap.Size(51, 23),
纪泽龙's avatar
纪泽龙 committed
437
          image: require("../assets/images/yalibiao.png")
438 439 440 441
        });
        marker.setIcon(icon);
        break;
      }
442 443 444 445 446 447 448 449
      case DEVICE_TYPE.INSPECTOR: {
        let icon = new AMap.Icon({
          //size: new AMap.Size(51, 23),
          image: require("../assets/images/zhibanrenyuan.png")
        });
        marker.setIcon(icon);
        break;
      }
耿迪迪's avatar
耿迪迪 committed
450
    }
耿迪迪's avatar
耿迪迪 committed
451 452 453 454 455 456
  }

  /**
   * 添加折线
   * @param path
   */
纪泽龙's avatar
纪泽龙 committed
457
  addPolyline(arr) {
纪泽龙's avatar
纪泽龙 committed
458
    // this` polyLines = [];
纪泽龙's avatar
纪泽龙 committed
459 460 461 462 463 464 465 466 467
    console.log("包装的数组", arr);
    for (let i = 0; i < arr.length; i++) {
      const item = arr[i];
      let { coordinates } = item;
      // console.log("coordinates",coordinates)
      // let path = coordinates ? getArray(coordinates) :[];
      // 字符串转二维数组

      let path = coordinates ? eval(coordinates) : [];
耿迪迪's avatar
耿迪迪 committed
468
      let polyline = new AMap.Polyline({
纪泽龙's avatar
纪泽龙 committed
469
        path,
纪泽龙's avatar
纪泽龙 committed
470
        strokeColor: "#F7FE38",
纪泽龙's avatar
1  
纪泽龙 committed
471
        strokeWeight: 4,
耿迪迪's avatar
耿迪迪 committed
472 473 474
        strokeOpacity: 0.9,
        zIndex: 50,
        bubble: true,
纪泽龙's avatar
纪泽龙 committed
475 476 477 478
        geodesic: true,
        extData: {
          type: "line",
          //当前line状态 0:正常状态 1:正在编辑状态
纪泽龙's avatar
纪泽龙 committed
479 480
          isState: 0,
          lineData: item
纪泽龙's avatar
纪泽龙 committed
481 482
        }
      });
纪泽龙's avatar
纪泽龙 committed
483

纪泽龙's avatar
纪泽龙 committed
484 485
      this.polyLines.push(polyline);
      // 信息窗体
纪泽龙's avatar
纪泽龙 committed
486
      const dom = createPop(lineInfoWindow, {
纪泽龙's avatar
纪泽龙 committed
487
        obj: { a: 123, editorPage: true, ...item, polyline }
纪泽龙's avatar
纪泽龙 committed
488
      });
纪泽龙's avatar
纪泽龙 committed
489

纪泽龙's avatar
纪泽龙 committed
490
      console.log("dom", dom.$el);
纪泽龙's avatar
纪泽龙 committed
491 492 493 494 495 496 497 498 499 500
      dom.$el.addEventListener("mouseover", () => {
        let options = this.myMap.getStatus();
        options.scrollWheel = false;
        this.myMap.setStatus(options);
      });
      dom.$el.addEventListener("mouseout", () => {
        let options = this.myMap.getStatus();
        options.scrollWheel = true;
        this.myMap.setStatus(options);
      });
纪泽龙's avatar
纪泽龙 committed
501
      let infoWindow = new AMap.InfoWindow({
纪泽龙's avatar
纪泽龙 committed
502
        isCustom: true,
纪泽龙's avatar
纪泽龙 committed
503
        autoMove: false,
纪泽龙's avatar
纪泽龙 committed
504
        content: dom.$el,
纪泽龙's avatar
纪泽龙 committed
505
        //信息船体偏移量
纪泽龙's avatar
纪泽龙 committed
506
        offset: new AMap.Pixel(0, 0),
纪泽龙's avatar
纪泽龙 committed
507 508 509
        anchor: "left-top"
      });

纪泽龙's avatar
纪泽龙 committed
510
      this.newLineAddEvent(polyline);
纪泽龙's avatar
纪泽龙 committed
511
      polyline.infoWindow = infoWindow;
纪泽龙's avatar
纪泽龙 committed
512 513
      //添加事件
      polyline.on("mouseover", e => {
纪泽龙's avatar
纪泽龙 committed
514
        if (this.lineType == 1) return;
纪泽龙's avatar
纪泽龙 committed
515 516 517 518 519
        // 上方导航的高
        const topBar = 81;
        // 坐标导航的宽
        const leftBar = 100;
        // 屏幕可视区的宽高
纪泽龙's avatar
纪泽龙 committed
520 521 522 523
        const {
          clientWidth: windowClientWidth,
          clientHeight: windowClientHeight
        } = document.body;
纪泽龙's avatar
纪泽龙 committed
524
        // 弹出的信息窗口的宽高
纪泽龙's avatar
纪泽龙 committed
525

纪泽龙's avatar
纪泽龙 committed
526 527 528 529
        const {
          offsetWidth: infoWindowWidth,
          offsetHeight: infoWindowHeight
        } = { offsetWidth: 406, offsetHeight: 316 };
纪泽龙's avatar
纪泽龙 committed
530
        // 鼠标碰到线后的位置
纪泽龙's avatar
纪泽龙 committed
531
        const { clientX: mouseClientX, clientY: mouseClientY } = e.originEvent;
纪泽龙's avatar
纪泽龙 committed
532
        // 鼠标到左边界的距离
纪泽龙's avatar
纪泽龙 committed
533
        const offsetLeftX = mouseClientX - 100;
纪泽龙's avatar
纪泽龙 committed
534
        // 鼠标到右边界的距离
纪泽龙's avatar
纪泽龙 committed
535 536 537
        const offsetRightX = windowClientWidth - mouseClientX;
        const offsetTopY = mouseClientY - 81;
        const offsetBottomY = windowClientHeight - mouseClientY;
纪泽龙's avatar
纪泽龙 committed
538

纪泽龙's avatar
纪泽龙 committed
539 540 541 542 543 544 545 546 547
        const offsetY = mouseClientY - 80 - infoWindowHeight;
        let X = 20,
          Y = -20;
        if (offsetLeftX <= infoWindowWidth) {
          console.log("靠左了");
          X = 20;
        } else if (offsetRightX <= infoWindowWidth) {
          console.log("靠右了");
          X = -infoWindowWidth - 20;
纪泽龙's avatar
纪泽龙 committed
548
        }
纪泽龙's avatar
纪泽龙 committed
549 550 551 552 553 554
        if (offsetTopY <= infoWindowHeight) {
          console.log("靠上了");
          Y = 20;
        } else if (offsetBottomY <= infoWindowHeight + 81) {
          console.log("靠下了");
          Y = -infoWindowHeight - 20;
纪泽龙's avatar
纪泽龙 committed
555 556
        }
        polyline.setOptions({ strokeColor: "#FF5A67" });
纪泽龙's avatar
纪泽龙 committed
557
        infoWindow.setOffset(new AMap.Pixel(X, Y));
纪泽龙's avatar
纪泽龙 committed
558
        infoWindow.open(map, e.lnglat);
纪泽龙's avatar
纪泽龙 committed
559 560
        // polyline.infoWindow=infoWindow;
        this.showInfoWindow = infoWindow;
纪泽龙's avatar
纪泽龙 committed
561

纪泽龙's avatar
纪泽龙 committed
562
        // const
纪泽龙's avatar
纪泽龙 committed
563 564
      });
      polyline.on("mouseout", e => {
纪泽龙's avatar
纪泽龙 committed
565
        polyline.setOptions({ strokeColor: "#F7FE38" });
纪泽龙's avatar
纪泽龙 committed
566
        // infoWindow.close();
纪泽龙's avatar
纪泽龙 committed
567
      });
纪泽龙's avatar
纪泽龙 committed
568
      // 计算info的位置
纪泽龙's avatar
纪泽龙 committed
569
      // function infoPosition() {}
纪泽龙's avatar
纪泽龙 committed
570 571 572 573 574 575 576
    }
    map.add(this.polyLines);
    // 缩放地图到合适的视野级别
    // map.setFitView();
  }
  // 创建一条新的线
  createNewLine() {
577
    map.remove(this.markerOverlays);
纪泽龙's avatar
纪泽龙 committed
578
    this.mouseTool.polyline({
纪泽龙's avatar
纪泽龙 committed
579
      // bubbles:false,
纪泽龙's avatar
1  
纪泽龙 committed
580
      strokeWeight: 4,
纪泽龙's avatar
纪泽龙 committed
581 582 583 584 585 586 587 588
      strokeColor: "#80d8ff",
      extData: {
        type: "newLine",
        //当前line状态 0:正常状态 1:正在编辑状态
        isState: 0
      }
      //同Polyline的Option设置
    });
纪泽龙's avatar
纪泽龙 committed
589 590
    // 让它不再等于null
    // this.newLineObj={a:123}
纪泽龙's avatar
纪泽龙 committed
591
  }
纪泽龙's avatar
纪泽龙 committed
592 593 594 595 596 597 598
  // 创建出来的新线归位,重置,当点击编辑跟删除的时候
  newLineReset() {
    this.lineFlag = false;
    if (this.mouserTool) {
      this.mouseTool.close();
    }
    if (this.newLineObj) {
纪泽龙's avatar
纪泽龙 committed
599
      this.newLineObj.polyEditor.close();
纪泽龙's avatar
纪泽龙 committed
600
      map.remove(this.newLineObj);
纪泽龙's avatar
纪泽龙 committed
601
      this.newLineObj = null;
纪泽龙's avatar
纪泽龙 committed
602 603
    }
  }
纪泽龙's avatar
纪泽龙 committed
604
  // 新建line增加编辑以及右键菜单
纪泽龙's avatar
纪泽龙 committed
605
  closeInfoWindow() {
纪泽龙's avatar
纪泽龙 committed
606
    this.showInfoWindow && this.showInfoWindow.close();
纪泽龙's avatar
纪泽龙 committed
607
    this.markerInfoWindow && this.markerInfoWindow.close();
纪泽龙's avatar
纪泽龙 committed
608 609 610 611
  }
  // 新line与老line添加点击事件
  newLineAddEvent(obj) {
    obj.polyEditor = new AMap.PolyEditor(map, obj);
纪泽龙's avatar
纪泽龙 committed
612 613 614 615 616
    // obj.polyEditor.on('adjust',(e)=>{
    //   console.log("addnode")
    // })
    obj.on("mousedown", e => {
      console.log(e.originEvent);
纪泽龙's avatar
纪泽龙 committed
617
      console.log("lineType", this.lineType);
纪泽龙's avatar
纪泽龙 committed
618 619
      this.lineFlag = true;
      // 每次点击关闭然后再次激活
纪泽龙's avatar
纪泽龙 committed
620 621 622 623
      // 如果是新线就关闭
      if (obj.getExtData().type == "newLine") {
        this.mouseTool.close();
      }
纪泽龙's avatar
纪泽龙 committed
624 625 626 627 628
      // 删除
      if (this.lineType == 3) {
        this.lineDelete(obj);
        return;
      }
纪泽龙's avatar
纪泽龙 committed
629
      // 获取当前状态 0普通状态,1是正编辑状态
纪泽龙's avatar
纪泽龙 committed
630
      const { isState, type } = obj.getExtData();
纪泽龙's avatar
纪泽龙 committed
631
      // 如果不是新线的时候并且没点编辑,点击是无效的
纪泽龙's avatar
纪泽龙 committed
632
      if (type != "newLine" && this.lineType != 2) return;
纪泽龙's avatar
纪泽龙 committed
633 634 635 636 637 638 639 640
      if (isState == 0) {
        // 如果是0,就打开编辑,变成编辑状态
        obj.polyEditor.open();
        let opstions = obj.getExtData();
        opstions.isState = 1;
        console.log(opstions);
        obj.setExtData(opstions);
      } else {
纪泽龙's avatar
纪泽龙 committed
641
        // 经纬度
纪泽龙's avatar
纪泽龙 committed
642
        const lnglatsArr = obj.getPath().map(item => [item.lng, item.lat]);
纪泽龙's avatar
纪泽龙 committed
643 644 645 646
        // 管道总长度
        const pipeLength = obj.getLength();
        // 传回来的数据 如果是新管道就是空
        const lineData = type == "newLine" ? {} : obj.getExtData().lineData;
纪泽龙's avatar
纪泽龙 committed
647
        // const lineData =  obj.getExtData().lineData;
纪泽龙's avatar
纪泽龙 committed
648 649 650 651 652 653 654 655
        console.log("lineData===================>传入组件的数据", lineData);
        this.infoWindowPipelineView({
          target: obj,
          lineType: type,
          lnglatsArr,
          pipeLength,
          lineData
        });
纪泽龙's avatar
纪泽龙 committed
656 657 658
      }
    });
  }
纪泽龙's avatar
纪泽龙 committed
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
  // 隐藏所有管道
  lineShow(bool) {
    bool
      ? this.polyLines.forEach(item => item.show())
      : this.polyLines.forEach(item => item.hide());
    if (this.newLineObj) {
      bool ? this.newLineObj.show() : this.newLineObj.hide();
    }
  }
  markerShow(type, bool) {
    this.markers.forEach(item => {
      const { deviceType } = item.getExtData();
      if (deviceType == type) {
        bool ? item.show() : item.hide();
      }
      // console.log("deviceType",deviceType);
    });
  }
677
  // 其实是修改了状态,不是真的删除
纪泽龙's avatar
纪泽龙 committed
678
  lineDelete(obj) {
纪泽龙's avatar
纪泽龙 committed
679
    const {
680
      lineData: { pipeName, deviceInfoList }
纪泽龙's avatar
纪泽龙 committed
681
    } = obj.getExtData();
682 683 684 685 686 687 688
    console.log("deviceInfoList", deviceInfoList);

    var devices = " ";
    for (var i = 0; i < deviceInfoList.length; i++) {
      var item = deviceInfoList[i];
      devices = devices + item.deviceName + " ";
    }
纪泽龙's avatar
纪泽龙 committed
689
    vue
690 691 692 693 694 695 696 697 698 699 700 701 702 703
      .$confirm(
        '请确认是否删除管道名称为"' +
          pipeName +
          '"的数据项,该管道下包含的设备(' +
          devices +
          ")将一并删除",
        "提示",
        {
          // confirmButtonText: "确定",
          // cancelButtonText: "取消",
          type: "warning"
          // center: true
        }
      )
纪泽龙's avatar
纪泽龙 committed
704
      .then(() => {
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
        const { lineData } = obj.getExtData();
        // updatePipe
        // delPipe(pipeId).then(res => {
        let upDataObj = { ...lineData };
        upDataObj.isDel = 1;
        updatePipe(upDataObj).then(res => {
          if (res.code == 200) {
            const index = this.polyLines.indexOf(obj);
            // 如果是老线,就要线删除原来的,然后重新包装一遍
            if (index >= 0) {
              this.polyLines.splice(index, 1);
              // 删除管道的时候,与管道管理额的设备也要删除
              for (var i = 0; i < deviceInfoList.length; i++) {
                const item = deviceInfoList[i];
                for (let j = 0; j < this.markers.length; j++) {
                  const item2 = this.markers[j];
                  if (item.deviceId == item2.getExtData().deviceId) {
                    map.remove(item2);
                    const ind = this.markers.indexOf(item2);
                    if (ind >= 0) {
                      this.markers.splice(ind, 1);
                    }
                    break;
                  }
                }
              }
              map.remove(obj);
            }
            vue.$message({
              type: "success",
              offset: 100,
              // center:true,
              message: "删除成功!"
            });
            // 关闭当前线条的infowindow
            // this.closeLineInfoWindow();
            console.log("改变线条");
纪泽龙's avatar
纪泽龙 committed
742 743 744
          }
        });
      })
745 746
      .catch(err => {
        console.log(err);
纪泽龙's avatar
纪泽龙 committed
747 748
        vue.$message({
          type: "info",
纪泽龙's avatar
纪泽龙 committed
749 750
          // center:true,
          offset: 100,
纪泽龙's avatar
纪泽龙 committed
751 752 753 754
          message: "已取消删除"
        });
      });
  }
纪泽龙's avatar
纪泽龙 committed
755 756 757 758
  // 关闭所有已经上传的线的编辑状态
  linePolyEditorAllClose() {
    this.polyLines.forEach(item => {
      item.polyEditor.close();
纪泽龙's avatar
纪泽龙 committed
759 760 761 762 763 764 765
      let opstions = item.getExtData();
      opstions.isState = 0;
      item.setExtData(opstions);

      let attr = item.getOptions();
      attr.strokeColor = "#F7FE38";
      item.setOptions(attr);
纪泽龙's avatar
纪泽龙 committed
766 767 768
    });
  }

纪泽龙's avatar
纪泽龙 committed
769
  // 传进组件的会调 点确认的时候调
纪泽龙's avatar
纪泽龙 committed
770
  lineOkCallBack(target, data) {
纪泽龙's avatar
纪泽龙 committed
771 772 773
    target.polyEditor.close();
    const index = this.polyLines.indexOf(target);
    // 如果是老线,就要线删除原来的,然后重新包装一遍
纪泽龙's avatar
纪泽龙 committed
774 775
    if (index >= 0) {
      this.polyLines.splice(index, 1);
耿迪迪's avatar
耿迪迪 committed
776
    }
纪泽龙's avatar
纪泽龙 committed
777 778
    console.log("data999-=================>传回来的data", data);
    this.addPolyline([data]);
纪泽龙's avatar
纪泽龙 committed
779 780
    map.remove(target);
    // console.log('polyLines',this.polyLines)
耿迪迪's avatar
耿迪迪 committed
781
  }
纪泽龙's avatar
纪泽龙 committed
782
  // 上传服务器用的组件
耿迪迪's avatar
耿迪迪 committed
783

纪泽龙's avatar
纪泽龙 committed
784
  infoWindowPipelineView(options) {
纪泽龙's avatar
纪泽龙 committed
785
    // const {} =options;
纪泽龙's avatar
纪泽龙 committed
786 787
    const notice = createPop(pipelineView, {
      title: "管道",
纪泽龙's avatar
纪泽龙 committed
788 789 790 791 792 793 794 795
      // 数据
      // lineData: options.lineData,
      // lnglatsArr:options.lnglatsArr,
      // pipeLength:options.pipeLength,
      // //线是新线还是老线
      // lineType: options.lineType,
      // target: options.obj,
      ...options,
纪泽龙's avatar
纪泽龙 committed
796
      //把当前对象当作that传进去
纪泽龙's avatar
纪泽龙 committed
797 798
      gaodeMap: this,
      lineOkCallBack: this.lineOkCallBack
纪泽龙's avatar
纪泽龙 committed
799 800 801
    });
    notice.show();
  }
耿迪迪's avatar
耿迪迪 committed
802 803 804
  /**
   * 添加鼠标事件
   */
纪泽龙's avatar
纪泽龙 committed
805
  addMouseTool() {
耿迪迪's avatar
耿迪迪 committed
806
    this.mouseTool = new AMap.MouseTool(map);
耿迪迪's avatar
耿迪迪 committed
807
    //监听draw事件可获取画好的覆盖物
耿迪迪's avatar
耿迪迪 committed
808 809
    this.overlays = [];
    let that = this;
耿迪迪's avatar
耿迪迪 committed
810
    this.markerOverlays = [];
纪泽龙's avatar
纪泽龙 committed
811 812
    this.mouseTool.on("draw", function(e) {
      if (e.obj.getExtData().type != "newLine") {
耿迪迪's avatar
耿迪迪 committed
813
        map.remove(that.markerOverlays);
814
        const device = that.createInfowindow("新增");
耿迪迪's avatar
耿迪迪 committed
815 816 817
        device.map = map;
        device.obj = e.obj;
        device.gaoMap = that;
纪泽龙's avatar
纪泽龙 committed
818
        e.obj.on("click", function(aa) {
纪泽龙's avatar
纪泽龙 committed
819
          let postion = aa.target._position;
820
          //兼容拖拽后单击事件,拖拽后点击事件返回位置为数组
纪泽龙's avatar
纪泽龙 committed
821
          if (postion instanceof Array) {
822 823
            device.form.longitude = postion[0];
            device.form.latitude = postion[1];
纪泽龙's avatar
纪泽龙 committed
824
          } else {
825 826 827 828
            device.form.longitude = postion.lng;
            device.form.latitude = postion.lat;
          }

纪泽龙's avatar
纪泽龙 committed
829
          device.show();
纪泽龙's avatar
纪泽龙 committed
830
        });
831
        e.obj.on("mouseover", function() {
832 833 834
          that.mouseTool.close();
        });

835
        e.obj.on("mouseout", function() {
836
          that.draw(that.deviceType);
837
        });
838

耿迪迪's avatar
耿迪迪 committed
839
        that.markerOverlays.push(e.obj);
纪泽龙's avatar
纪泽龙 committed
840
      }
841

纪泽龙's avatar
纪泽龙 committed
842 843
      if (e.obj && e.obj.getExtData().type == "newLine") {
        console.log("挂上事件");
纪泽龙's avatar
纪泽龙 committed
844
        that.newLineAddEvent(e.obj);
纪泽龙's avatar
纪泽龙 committed
845
        // 记录这条线
纪泽龙's avatar
纪泽龙 committed
846 847
        // console.log(e.obj.getPath().length)
        // 如果只有一个点,并没有连成线的时候就不close 大于一个点的时候才执行clse
848
        console.log(that.lineType);
纪泽龙's avatar
纪泽龙 committed
849 850 851 852 853 854
        if (e.obj.getPath().length > 1) {
          that.newLineObj = e.obj;
          that.mouseTool.close();
        } else {
          // that.newLineObj = null;
        }
纪泽龙's avatar
纪泽龙 committed
855
        // 关闭
纪泽龙's avatar
纪泽龙 committed
856 857 858
        // 创建一条新线,然后在点地图的时候删除原来的旧线
        // that.createNewLine();

纪泽龙's avatar
纪泽龙 committed
859 860 861
        // 右键菜单
        // that.addEditorAndMenu(e.obj)
      }
耿迪迪's avatar
耿迪迪 committed
862

纪泽龙's avatar
纪泽龙 committed
863 864 865
      // if(e.obj.getExtData().type=="line"){
      //   return;
      // }
耿迪迪's avatar
耿迪迪 committed
866
      //that.mouseTool.close();
纪泽龙's avatar
纪泽龙 committed
867
      that.overlays.push(e.obj);
耿迪迪's avatar
耿迪迪 committed
868
    });
耿迪迪's avatar
耿迪迪 committed
869
  }
耿迪迪's avatar
耿迪迪 committed
870

871 872 873
  /**
   * 创建弹框事件
   */
874
  createInfowindow(val) {
纪泽龙's avatar
纪泽龙 committed
875 876
    switch (this.deviceType) {
      case DEVICE_TYPE.PIPEPLINE: {
877 878
        break;
      }
纪泽龙's avatar
纪泽龙 committed
879
      case DEVICE_TYPE.REGEULATORBOX: {
880
        return createPop(regulatorBox, {
881
          title: val + "调压箱"
882 883
        });
      }
纪泽龙's avatar
纪泽龙 committed
884
      case DEVICE_TYPE.VALUEWELL: {
885
        return createPop(valveWell, {
886
          title: val + "阀门井"
887 888
        });
      }
纪泽龙's avatar
纪泽龙 committed
889
      case DEVICE_TYPE.FLOWMETER: {
890
        return createPop(flowMeter, {
891
          title: val + "流量计"
892 893
        });
      }
894
      case DEVICE_TYPE.PRESSUREGAGE: {
纪泽龙's avatar
纪泽龙 committed
895
        return createPop(pressureGage, {
896
          title: val + "压力表"
897 898
        });
      }
899
    }
耿迪迪's avatar
耿迪迪 committed
900
  }
耿迪迪's avatar
耿迪迪 committed
901

902 903 904 905
  /**
   * 鼠标画图事件
   * @param deviceType 设备类型
   */
纪泽龙's avatar
纪泽龙 committed
906
  draw(deviceType) {
耿迪迪's avatar
耿迪迪 committed
907
    let that = this;
908
    that.deviceType = deviceType;
纪泽龙's avatar
纪泽龙 committed
909 910 911
    if (
      DEVICE_TYPE.REGEULATORBOX == deviceType ||
      DEVICE_TYPE.VALUEWELL == deviceType ||
912 913
      DEVICE_TYPE.FLOWMETER == deviceType ||
      DEVICE_TYPE.PRESSUREGAGE == deviceType
纪泽龙's avatar
纪泽龙 committed
914
    ) {
915 916 917 918
      that.mouseTool.marker({
        draggable: true
      });
    }
纪泽龙's avatar
纪泽龙 committed
919
    if (DEVICE_TYPE.PIPEPLINE == deviceType) {
920 921
      that.mouseTool.polyline({
        strokeWeight: 9,
纪泽龙's avatar
纪泽龙 committed
922
        strokeColor: "#80d8ff"
923 924 925
        //同Polyline的Option设置
      });
    }
耿迪迪's avatar
耿迪迪 committed
926 927
  }

耿迪迪's avatar
耿迪迪 committed
928 929 930
  /**
   * 添加地图控件
   */
纪泽龙's avatar
纪泽龙 committed
931 932 933 934 935 936 937 938 939 940 941 942
  addMapControl() {
    AMap.plugin(
      [
        "AMap.ToolBar",
        "AMap.Scale",
        "AMap.HawkEye",
        "AMap.MapType",
        "AMap.Geolocation"
      ],
      function() {
        // 在图面添加工具条控件,工具条控件集成了缩放、平移、定位等功能按钮在内的组合控件
        //map.addControl(new AMap.ToolBar());
耿迪迪's avatar
耿迪迪 committed
943

纪泽龙's avatar
纪泽龙 committed
944 945
        // 在图面添加比例尺控件,展示地图在当前层级和纬度下的比例尺
        map.addControl(new AMap.Scale());
耿迪迪's avatar
耿迪迪 committed
946

纪泽龙's avatar
纪泽龙 committed
947 948
        // 在图面添加鹰眼控件,在地图右下角显示地图的缩略图
        map.addControl(new AMap.HawkEye({ isOpen: true }));
耿迪迪's avatar
耿迪迪 committed
949

纪泽龙's avatar
纪泽龙 committed
950 951 952 953
        // 在图面添加类别切换控件,实现默认图层与卫星图、实施交通图层之间切换的控制
        map.addControl(
          new AMap.MapType({ position: { top: "10px", left: "100px" } })
        );
耿迪迪's avatar
耿迪迪 committed
954

纪泽龙's avatar
纪泽龙 committed
955 956 957 958
        // 在图面添加定位控件,用来获取和展示用户主机所在的经纬度位置
        // map.addControl(new AMap.Geolocation());
      }
    );
耿迪迪's avatar
耿迪迪 committed
959
  }
960

纪泽龙's avatar
纪泽龙 committed
961
  searchTips(inputId) {
962
    let that = this;
纪泽龙's avatar
纪泽龙 committed
963
    AMap.plugin(["AMap.AutoComplete", "AMap.PlaceSearch"], function() {
964
      //输入提示
纪泽龙's avatar
z  
纪泽龙 committed
965 966 967 968
      // var autoOptions = {
      //   input: inputId
      // };
      // let auto = new AMap.AutoComplete(autoOptions);
969 970 971 972
      that.placeSearch = new AMap.PlaceSearch({
        map: map
      });
      //构造地点查询类
纪泽龙's avatar
z  
纪泽龙 committed
973 974 975 976
      // auto.on("select", function(e) {
      //   that.searchSelectAdcode = e.poi.adcode;
      //   that.searchSelectName = e.poi.name;
      // });
纪泽龙's avatar
纪泽龙 committed
977
    });
978 979
  }

纪泽龙's avatar
纪泽龙 committed
980
  closeAddMarker() {
耿迪迪's avatar
耿迪迪 committed
981 982 983
    this.mouseTool.close();
    map.remove(this.markerOverlays);
  }
984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002
  // 只上图没功能
  onlyLine(obj) {
    const { coordinates, pipeName } = obj;
    let polyline = new AMap.Polyline({
      path: eval(coordinates),
      strokeColor: "#80d8ff",
      strokeWeight: 4,
      strokeOpacity: 0.9,
      zIndex: 50,
      bubble: true,
      geodesic: true,
      extData: {
        type: "line",
        //当前line状态 0:正常状态 1:正在编辑状态
        isState: 0,
        lineData: obj
      }
    });
    let infoWindow = new AMap.InfoWindow({
1003
      isCustom: true,
1004 1005
      content: `<span style='border:1px solid #80d8ff;background:#fff'>${pipeName}</span>`,
      anchor: "left-top",
1006
      offset: new AMap.Pixel(20, -20)
1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022
    });
    polyline.on("mouseover", e => {
      const options = polyline.getOptions();
      options.strokeColor = "#FF5A67";
      polyline.setOptions(options);
      infoWindow.open(map, e.lnglat);
    });
    polyline.on("mouseout", e => {
      const options = polyline.getOptions();
      options.strokeColor = "#80d8ff";
      polyline.setOptions(options);
      infoWindow.close();
    });
    map.add(polyline);
    const path = eval(coordinates)[0];
    // map.setFitView();
1023
    map.setCenter([+path[0], +path[1]], false);
1024 1025 1026 1027 1028 1029

    // const lntlat = eval(coordinates)[0];
    // map.panTo(lntlat)

    // 信息窗体
  }
耿迪迪's avatar
耿迪迪 committed
1030 1031
}
export default gaodeMap;