上饶市警务平台后台管理前端
zhongrj
2025-01-21 c393f8b721c1e7f6ea65ff0f3ad3a47dce71cfbc
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
139
<template>
  <div class="basic-container">
    <div class="search-line">
      <el-select
        class="search-input"
        v-model="queryString"
        filterable
        remote
        reserve-keyword
        placeholder="请输入关键词"
        :remote-method="remoteMethod"
        :loading="loading"
        @change="selectChange">
        <el-option
          v-for="item in searchList"
          :key="item.uid"
          :label="item.address"
          :value="JSON.stringify(item)">
        </el-option>
      </el-select>
      <!--      <el-button class="search-button" @click="getAddressByQuery">查询</el-button>-->
    </div>
    <!--    <search-map-box ref="OpenLayersMap" @getMapData="getMapData" :route-range="point" :is-detail="true"></search-map-box>-->
    <dc-search-map ref="dcSearchMap" @getMapData="getMapData" :point="point"></dc-search-map>
  </div>
</template>
 
<script>
import SearchMapBox from "@/components/map/searchMapBox";
import {getAoiByPt, search, searchByLonLat, searchByQuery} from "@/api/security/security";
import data from "@/views/util/data";
import DcSearchMap from "@/components/map/dcSearchMap";
 
export default {
  name: "searchMap",
  components: {DcSearchMap, SearchMapBox},
  props: ['pointLonLat'],
  data() {
    return {
      ak: "ebf48ecaa1fd436fa3d40c4600aa051f",
      region: "361100",
      longitude: "",
      latitude: "",
      queryString: "",
      point: "",
      searchList: [],
      loading: false,
    }
  },
  watch: {
    longitude: {
      handler(newVal) {
        if (newVal) {
          this.getAddressByLonLat()
        }
      }
    }
  },
  created() {
    this.point = this.pointLonLat
  },
  mounted() {
    this.$refs.dcSearchMap.init()
  },
  methods: {
    getMapData(data) {
      this.longitude = data[0]
      this.latitude = data[1]
      this.$emit("getLonLat", data)
      
    },
    remoteMethod(data) {
      this.queryString = data
      this.getAddressByQuery()
    },
    getAddressByQuery() {
      let ak = this.ak
      let region = this.region
      let query = this.queryString
      searchByQuery(ak, region, query).then(res => {
        let dataList = res.data.result
        this.searchList = dataList
      })
    },
    getAddressByLonLat() {
      let ak = this.ak
      let query = ""
      let region = this.region
      let region_type = "circle"
      let page_size = "1"
      let page_num = "1"
      let infos = 1
      let radius = 100
      let location = this.longitude + " " + this.latitude
      searchByLonLat(ak, query, region, region_type, page_size, page_num, infos, radius, location).then(res => {
        let data = res.data.result[0]
        if(data!=undefined){
          this.queryString = data.address
          this.$emit("getAddress", this.queryString)
          let point = [data.location.lng,data.location.lat]
          this.$emit("getLonLat", point)
          //清空
          this.searchList = []
          //触发搜索
          this.getAddressByQuery()
        }else{
          this.queryString = [];
          //清空
          this.searchList = []
          this.$emit("getAddress", '')
          this.$emit("getLonLat", ['',''])
        }
        
      })
    },
    selectChange(data) {
      let selectData = JSON.parse(data)
 
      this.$emit("getLonLat", [selectData.location.lng, selectData.location.lat])
      this.$emit("getAddress", selectData.address)
 
      this.$refs.dcSearchMap.setView(selectData.location)
    }
  }
}
</script>
 
<style scoped>
.search-line {
  display: flex;
  width: 1286px;
}
 
.search-input {
  margin-bottom: 2%;
  width: 100%;
}
 
</style>