派生自 wuyushui/SewerAndRainNetwork

陈泽平
2021-05-29 b3d9e0d7a9479ba8e615a82e6f454fd2ebf62ac6
src/components/base-page/enterprise-emergency/events-reported/ReportLocation.vue
@@ -20,7 +20,8 @@
                        </el-form>
                    </div>
                    <div class="place-right">
                        <el-button type="primary" @click="mapPoints">定位</el-button>
                        <el-button type="primary" size="small" @click="mapPoints">点击定位</el-button>
                        <el-button type="primary" size="small" @click="dataPoints">数据定位</el-button>
                    </div>
                </el-row>
                <div class="place-bottom" style="text-align: center;margin: 5px">
@@ -36,6 +37,8 @@
// 管段定位组件
import ReportLocationSection from './ReportLocationSection'
import ReportLocationSearch from './ReportLocationSearch'
import { pulseEffect } from '../../../../utils/utils'
import iconUrl from '../../../../../public/assets/images/map/loc.png'
@@ -56,36 +59,16 @@
      }
    }
  },
  // mounted () {
  //   // 接收规定 每次重新选择定位 都指定 选择第一个开始
  //   eventBus.$on('tab-change', (obj) => {
  //     this.activeName = obj
  //   })
  // },
  methods: {
    // 地图上点击
    selectPipeLine () {
      window.map.on('click', this.selectClick)
      // window.mapManager.clickDialogSwitch = false
    },
    // 地图上点击回调
    selectClick (e) {
      window.map.off('click', this.selectClick)
      // const point = [e.latlng.lng, e.latlng.lat]
      const pointX = e.latlng.lng
      const pointY = e.latlng.lat
      // let marker = window.L.marker(point,{
      //
      // })
      this.clickLocation = '\'' + pointX + '\'' + pointY + ''
      this.mapPointResult(e)
    },
    mapPointResult (e) {
      console.log(e)
      this.LongLatPos.longPos = e.latlng.lng
      this.LongLatPos.latPos = e.latlng.lat
      const as = [e.latlng.lat, e.latlng.lng]
    // 点击定位
    mapPoints () {
      window.map.on('click', (e) => {
        this.LongLatPos.longPos = parseFloat(e.latlng.lng).toFixed(6)
        this.LongLatPos.latPos = parseFloat(e.latlng.lat).toFixed(6)
        const as = [this.LongLatPos.latPos, this.LongLatPos.longPos]
      // console.log(as)
        window.map.setView(as, 17)
        pulseEffect(as)
      const marker = window.L.marker(as, {
        icon: window.L.icon({
          iconUrl: iconUrl,
@@ -94,14 +77,25 @@
        })
      })
      window.map.addLayer(marker)
        window.map.off('click')
      })
    },
    // 获得焦点 进行定位
    focusLocation () {
      this.selectPipeLine()
    },
    // 经纬度定位
    mapPoints () {
      this.selectPipeLine()
    // 通过数据定位
    dataPoints () {
      const as = [this.LongLatPos.latPos, this.LongLatPos.longPos]
      // console.log(as)
      window.map.setView(as, 17)
      pulseEffect(as)
      const marker = window.L.marker(as, {
        icon: window.L.icon({
          iconUrl: iconUrl,
          iconSize: [30, 30],
          iconAnchor: [15, 15]
        })
      })
      window.map.addLayer(marker)
      this.LongLatPos.latPos = ''
      this.LongLatPos.longPos = ''
    },
    // 点击确认按钮事件
    confirm () {