修改定位弹窗的poi搜索优化
This commit is contained in:
@@ -382,6 +382,7 @@ export default {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
|
||||||
.operation {
|
.operation {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ export default {
|
|||||||
map: null,
|
map: null,
|
||||||
AMap: null,
|
AMap: null,
|
||||||
selected: {},
|
selected: {},
|
||||||
geo: null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -63,33 +62,19 @@ export default {
|
|||||||
this.selected = {location: res.lnglat}
|
this.selected = {location: res.lnglat}
|
||||||
this.poi?.searchNearBy('', res.lnglat, 100)
|
this.poi?.searchNearBy('', res.lnglat, 100)
|
||||||
});
|
});
|
||||||
|
this.poi = new AMap.PlaceSearch({map: this.map}).on('markerClick', ({data}) => {
|
||||||
|
const {name, location} = data
|
||||||
|
this.selected = {location, name}
|
||||||
|
})
|
||||||
if (this.latlng) {
|
if (this.latlng) {
|
||||||
let marker = new AMap.Marker({
|
this.map.add(new AMap.Marker({
|
||||||
position: [this.latlng.lng, this.latlng.lat]
|
position: [this.latlng.lng, this.latlng.lat]
|
||||||
})
|
}))
|
||||||
this.map.add(marker)
|
|
||||||
}
|
}
|
||||||
this.poi = new AMap.PlaceSearch().on('complete', ({poiList}) => {
|
this.map.addControl(new AMap.Geolocation({
|
||||||
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.geo = new AMap.Geolocation({
|
|
||||||
enableHighAccuracy: true,//是否使用高精度定位
|
enableHighAccuracy: true,//是否使用高精度定位
|
||||||
zoomToAccuracy: true//定位成功后是否自动调整地图视野到定位点
|
zoomToAccuracy: true//定位成功后是否自动调整地图视野到定位点
|
||||||
})
|
}))
|
||||||
this.map.addControl(this.geo)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
handleSearch(v) {
|
handleSearch(v) {
|
||||||
|
|||||||
Reference in New Issue
Block a user