This commit is contained in:
yanran200730
2022-03-21 15:01:51 +08:00
parent 9039ece985
commit d8e4916bbc
2 changed files with 15 additions and 4 deletions

View File

@@ -30,9 +30,7 @@ export default {
prop: "visible",
event: "visible",
},
props: {
visible: Boolean
},
props: ['latlng', 'visible'],
data() {
return {
dialog: false,
@@ -57,13 +55,21 @@ export default {
plugins: ['AMap.PlaceSearch', 'AMap.Marker', 'AMap.Geolocation'],
}).then(AMap => {
this.AMap = AMap
console.log(this.latlng)
this.map = new AMap.Map('amap', {
zoom: 14,
center: this.latlng ? [this.latlng.lng, this.latlng.lat] : ''
}).on('click', res => {
this.map.clearMap()
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) {