checkPipeLineLocation.vue 3.13 KB
Newer Older
1 2 3 4
<template>
  <el-dialog
    title="拾取坐标"
    :visible.sync="dialogTableVisible"
5
    :before-close="handleClose"
6 7 8 9 10 11 12
  >
    <div style="postion:relative">
      <el-row :span="8" class="button">
        <el-input id="ss" placeholder="输入地址" v-model="keyWorld"  ></el-input>
        <el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
      </el-row>
    </div>
yaqizhang's avatar
yaqizhang committed
13
    <div style="" id="container1" ref="elD"></div>
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    <el-row class="lt">
      <el-button type="primary" size="small" @click="confirmFun">确定</el-button>
      <el-button size="small" @click="$emit('dialogcancelFun')">取消</el-button>
    </el-row>
  </el-dialog>
</template>
<script>
  import gaodeMap from "./js/gaodeMapDialog.js";
  import { getString } from "@/utils/gassafety.js";
  export default {
    props: {
      dialogTableVisible: {
        type:Boolean,
      },
      slat: 0,
      slng: 0,
      str:{
        type:String,
      }

    },
    data(){
      return{
        lnglat: {
          lat: "",
          lng: ""
        },
        keyWorld: "",
        map:{},
        div:null,

      }
    },
    watch:{
      dialogTableVisible:{
        handler(value) {
          if(value){
            window.addEventListener("click", this.barClose);
            this.$nextTick(() => {
              this.map = new gaodeMap("石家庄");
              this.map.addMouseTool();
              if(this.str){
                this.map.addPolyline([{coordinates:this.str}]);
              }

              this.map.lineType = 1;
              if (this.map.newLineObj == null) {
                this.map.createNewLine();
              }

            })
          }else{
             console.log("清除事件")
            window.removeEventListener("click", this.barClose);
          }
        },
        // 代表在wacth里声明了firstName这个方法之后立即先去执行handler方法
        immediate: true

      }
    },
    methods:{
      confirmFun(){
        console.log("path",this.map.newLineObj.getPath())
        const pathArr = this.map.newLineObj.getPath().map(item=>{
          return [
            item.lng,item.lat
          ]
        })
        const str = getString(pathArr)
        this.$emit('confirmFun',str);
        this.$emit('dialogcancelFun');
      },
      search(){
        this.placeSearch.search(this.keyWorld);  //关键字查询查询
      },
90 91 92
      handleClose(){
        this.$emit('dialogcancelFun');
      },
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
      barClose() {
        console.log("window");
        this.deviceType = false;
        // 关闭当前线条的infowindow
        this.map.closeInfoWindow();
        this.map.lineFlag = false;
      },
    },

    beforeDestroy() {
    },
  }

</script>

<style scoped lang="scss">
  .dialog{
    position:relative;
  }
yaqizhang's avatar
yaqizhang committed
112
  #container1{
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
    width: 100%;
    height: 500px;
  }
  .lt{
    margin-top: 15px;
    text-align: right;
  }
  .lt .el-input {
    width: 120px;
    margin-right: 15px;
    display: inline-block;
  }

  .button{
    position: absolute;
    top: 90px;
    left: 30px;
    z-index: 999;
  }

  .button .el-input{
    width: 180px;
    margin-right: 10px;
    display: inline-block;
  }
</style>