修改定位弹窗的poi搜索优化
This commit is contained in:
@@ -39,7 +39,6 @@ export default {
|
||||
map: null,
|
||||
AMap: null,
|
||||
selected: {},
|
||||
geo: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -63,33 +62,19 @@ export default {
|
||||
this.selected = {location: res.lnglat}
|
||||
this.poi?.searchNearBy('', res.lnglat, 100)
|
||||
});
|
||||
if (this.latlng) {
|
||||
let marker = new AMap.Marker({
|
||||
position: [this.latlng.lng, this.latlng.lat]
|
||||
})
|
||||
this.map.add(marker)
|
||||
}
|
||||
this.poi = new AMap.PlaceSearch().on('complete', ({poiList}) => {
|
||||
this.map.clearMap()
|
||||
if (poiList?.length > 0) {
|
||||
poiList?.pois?.map(e => {
|
||||
let marker = new AMap.Marker({
|
||||
position: e.location,
|
||||
}).on('click', () => this.selected = e)
|
||||
this.map.add(marker)
|
||||
})
|
||||
} else {
|
||||
let marker = new AMap.Marker({
|
||||
position: this.selected.location,
|
||||
})
|
||||
this.map.add(marker)
|
||||
}
|
||||
this.poi = new AMap.PlaceSearch({map: this.map}).on('markerClick', ({data}) => {
|
||||
const {name, location} = data
|
||||
this.selected = {location, name}
|
||||
})
|
||||
this.geo = new AMap.Geolocation({
|
||||
if (this.latlng) {
|
||||
this.map.add(new AMap.Marker({
|
||||
position: [this.latlng.lng, this.latlng.lat]
|
||||
}))
|
||||
}
|
||||
this.map.addControl(new AMap.Geolocation({
|
||||
enableHighAccuracy: true,//是否使用高精度定位
|
||||
zoomToAccuracy: true//定位成功后是否自动调整地图视野到定位点
|
||||
})
|
||||
this.map.addControl(this.geo)
|
||||
}))
|
||||
})
|
||||
},
|
||||
handleSearch(v) {
|
||||
@@ -114,7 +99,7 @@ export default {
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.AiLocateDialog {
|
||||
:deep( .el-dialog__body ){
|
||||
:deep( .el-dialog__body ) {
|
||||
padding: 0;
|
||||
height: 480px;
|
||||
position: relative;
|
||||
|
||||
Reference in New Issue
Block a user