派生自 wuyushui/SewerAndRainNetwork

seatonwan9
2021-05-28 dd9af28934e9b34f74a58cf3f92a472b898d738e
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<template>
    <div class="click-location">
        <el-row>
            <el-input type="text" v-model="clickLocation" clearable @change="focusLocation"></el-input>
        </el-row>
        <el-row>
            <el-button type="primary" @click="confirm" style="text-align: right">确认</el-button>
        </el-row>
    </div>
</template>
 
<script>
 
import { reportLocationSearch } from '../../../../api/request'
import { pulseEffect } from '../../../../utils/utils'
export default {
  name: 'ReportLocationSearch',
  data () {
    return {
      // 点击定位绑定数据
      clickLocation: ''
    }
  },
  methods: {
    // 获得焦点 进行定位
    focusLocation () {
      // console.log(this.clickLocation)
      // console.log(window.map.getZoom())
      // console.log(window.map.getBounds())
      const getBoundsData = '' + window.map.getBounds()._southWest.lng + ',' + window.map.getBounds()._southWest.lat + ',' + window.map.getBounds()._northEast.lng + ',' + window.map.getBounds()._northEast.lat
      const data = {
        postStr: {
          keyWord: this.clickLocation,
          level: window.map.getZoom(),
          mapBound: getBoundsData,
          queryType: 7,
          count: 14,
          start: 0,
          queryTerminal: 10000
        },
        type: 'query'
      }
      // console.log(data)
      reportLocationSearch(data).then(res => {
        console.log(res)
        // const as = res.pois[0].lonlat.trim().split(' ')
        // window.map.setView([as[1], as[0]], 17)
        // pulseEffect([as[1], as[0]])
        for (let i = 0; i < res.pois.length; i++) {
          const as = res.pois[i].lonlat.trim().split(' ')
          if (res.pois[i].name.indexOf(this.clickLocation) >= 0) {
            window.map.setView([as[1], as[0]], 17)
            pulseEffect([as[1], as[0]])
          }
        }
      })
    },
    // 点击确认按钮事件
    confirm () {
      // 通过子组件向父组件传递数据
      this.$emit('locationClick', this.LongLatPos)
      console.log('搜索定位')
    }
  }
}
</script>
 
<style lang="less" scoped>
    .click-location {
        margin: 0 auto;
        text-align: center;
 
        .el-input {
            width: 80%;
            margin: 15px auto;
        }
 
        .el-button {
            margin: 15px auto;
        }
    }
</style>