2022-10-24 13:57:01 +08:00
|
|
|
<template>
|
2022-10-31 15:00:56 +08:00
|
|
|
<div class="searchOption">
|
|
|
|
|
<div>
|
|
|
|
|
<input id="keyword"
|
|
|
|
|
v-model="searchStyle"
|
|
|
|
|
type="radio"
|
|
|
|
|
value="keyword">
|
|
|
|
|
<label for="keyword">按关键字搜索</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<input id="lnglat"
|
|
|
|
|
v-model="searchStyle"
|
|
|
|
|
type="radio"
|
|
|
|
|
value="lnglat">
|
|
|
|
|
<label for="lnglat">按经纬度搜索</label>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
2022-10-24 13:57:01 +08:00
|
|
|
<div class="content">
|
|
|
|
|
<img src="@/assets/img/location.png">
|
2022-10-31 15:00:56 +08:00
|
|
|
<input v-model="searchContent"
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="请输入搜索位置/坐标"
|
|
|
|
|
@input="searchPlace()">
|
2022-10-24 13:57:01 +08:00
|
|
|
<img src="@/assets/img/search.png"
|
|
|
|
|
@click="showList()">
|
|
|
|
|
</div>
|
|
|
|
|
<div ref="locationList"
|
2022-10-31 15:00:56 +08:00
|
|
|
class="my-click-transition">
|
|
|
|
|
<li v-for="(item,index) in localList"
|
|
|
|
|
:key="index"
|
|
|
|
|
class="itemLocation"
|
|
|
|
|
@click="flyTo(item.geometry,item.id)"><img src="@/assets/img/location.png">
|
|
|
|
|
<span class="locationName">{{ item.name }}</span>
|
|
|
|
|
<span class="locationAddress">{{ item.address }}</span>
|
|
|
|
|
</li>
|
|
|
|
|
</div>
|
2022-10-24 13:57:01 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-10-31 15:00:56 +08:00
|
|
|
import axios from 'axios'
|
2022-10-24 13:57:01 +08:00
|
|
|
export default {
|
2022-10-31 15:00:56 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
searchType: '',
|
|
|
|
|
searchStyle: 'keyword',
|
|
|
|
|
searchContent: '',
|
|
|
|
|
localList: []
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-10-24 13:57:01 +08:00
|
|
|
methods: {
|
|
|
|
|
showList () {
|
2022-10-31 15:00:56 +08:00
|
|
|
// if (this.$refs.locationList.className == 'my-click-transition') {
|
|
|
|
|
// this.$refs.locationList.className = 'locationList'
|
|
|
|
|
// } else {
|
|
|
|
|
// this.$refs.locationList.className = 'my-click-transition'
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
// 实时查询
|
|
|
|
|
searchPlace () {
|
|
|
|
|
let url
|
|
|
|
|
if (this.searchStyle == 'keyword') {
|
|
|
|
|
console.log('111')
|
|
|
|
|
url = 'http://192.168.11.35:8500/thmap/poi/searchFeat/keywords?keywords=' + this.searchContent
|
2022-10-24 13:57:01 +08:00
|
|
|
} else {
|
2022-10-31 15:00:56 +08:00
|
|
|
console.log('222')
|
|
|
|
|
const arr = this.searchContent.split(',')
|
|
|
|
|
url = 'http://192.168.11.35:8500/thmap/poi/searchFeat/keywords?lat=' + arr[0] + '&lng=' + arr[1] + '&distance=' + 50
|
2022-10-24 13:57:01 +08:00
|
|
|
}
|
2022-10-31 15:00:56 +08:00
|
|
|
|
|
|
|
|
axios.get(url).then((res) => {
|
|
|
|
|
// console.log(res.data.data.datas, '数据集')
|
|
|
|
|
if (res.data.data.datas) {
|
|
|
|
|
// console.log('有数据了')
|
|
|
|
|
this.$refs.locationList.className = 'locationList'
|
|
|
|
|
this.localList = res.data.data.datas
|
|
|
|
|
} else {
|
|
|
|
|
this.$refs.locationList.className = 'my-click-transition'
|
|
|
|
|
}
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
console.log(err)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
flyTo (lonLatInfo, id) {
|
|
|
|
|
const Arr = lonLatInfo.split(' ')
|
|
|
|
|
|
|
|
|
|
// const Num1 = parseFloat(Arr[1])
|
|
|
|
|
const Num1 = Number(Arr[1].match(/\d+(\.\d+)?/g)[0])
|
|
|
|
|
const Num2 = Number(Arr[2].match(/\d+(\.\d+)?/g)[0])
|
|
|
|
|
const Arr1 = [Num1, Num2]
|
|
|
|
|
// console.log(this.$parent, '父组件')
|
|
|
|
|
this.$parent.flyTo(Arr1, id)
|
|
|
|
|
// // console.log(Arr1, '点位信息')
|
2022-10-24 13:57:01 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2022-10-31 15:00:56 +08:00
|
|
|
.searchOption {
|
|
|
|
|
width: 300px;
|
|
|
|
|
height: 50px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
padding: 0 15px;
|
|
|
|
|
line-height: 50px;
|
|
|
|
|
input {
|
|
|
|
|
margin-right: 5px;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-24 13:57:01 +08:00
|
|
|
.content {
|
|
|
|
|
width: 300px;
|
|
|
|
|
height: 45px;
|
|
|
|
|
padding: 10px 10px;
|
|
|
|
|
background-color: rgba(245, 245, 245, 0.8);
|
|
|
|
|
box-shadow: 0px 15px 10px -15px #565656;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
input {
|
|
|
|
|
padding-left: 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 位置列表
|
|
|
|
|
.locationList {
|
|
|
|
|
margin-top: 5px;
|
|
|
|
|
width: 300px;
|
2022-10-31 15:00:56 +08:00
|
|
|
// height: 100px;
|
|
|
|
|
background-color: rgba(245, 245, 245, 0.8);
|
|
|
|
|
transition: height 0.5s ease-in;
|
|
|
|
|
-webkit-transform: height 0.5s ease-in;
|
2022-10-24 13:57:01 +08:00
|
|
|
}
|
|
|
|
|
.my-click-transition {
|
2022-10-31 15:00:56 +08:00
|
|
|
overflow: hidden;
|
|
|
|
|
margin-top: 5px;
|
|
|
|
|
transition: height 0.5s ease-out;
|
|
|
|
|
-webkit-transform: height 0.5s ease-out;
|
|
|
|
|
height: 0;
|
|
|
|
|
width: 300px;
|
|
|
|
|
background-color: rgba(245, 245, 245, 0.8);
|
|
|
|
|
}
|
|
|
|
|
.itemLocation {
|
|
|
|
|
width: 300px;
|
|
|
|
|
height: 32px;
|
|
|
|
|
position: relative;
|
|
|
|
|
padding-left: 32px;
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
line-height: 32px;
|
|
|
|
|
list-style: none;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
img {
|
|
|
|
|
width: 26px;
|
|
|
|
|
height: 26px;
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 3px;
|
|
|
|
|
left: 0px;
|
|
|
|
|
}
|
|
|
|
|
.locationName {
|
|
|
|
|
color: #0082e5;
|
|
|
|
|
}
|
|
|
|
|
.locationAddress {
|
|
|
|
|
color: #565656;
|
|
|
|
|
}
|
2022-10-24 13:57:01 +08:00
|
|
|
}
|
|
|
|
|
</style>
|