|
|
@ -47,22 +47,35 @@ export default { |
|
|
|
] |
|
|
|
} |
|
|
|
}, |
|
|
|
// created() { |
|
|
|
// this.getEnergyBoardFn() |
|
|
|
// }, |
|
|
|
mounted() { |
|
|
|
created() { |
|
|
|
this.getEnergyBoardFn() |
|
|
|
// this.initAMap() |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
this.initAMap() |
|
|
|
}, |
|
|
|
unmounted() { |
|
|
|
this.map?.destroy() |
|
|
|
}, |
|
|
|
// 侦听器 |
|
|
|
watch: { |
|
|
|
markBoardDataList: { |
|
|
|
// 自动触发,只能使用handler |
|
|
|
handler(newVal, oldVal) { |
|
|
|
this.initAMap() |
|
|
|
// console.log(newVal); |
|
|
|
// console.log(oldVal); |
|
|
|
}, |
|
|
|
// true表示侦听器立即触发(immediate默认为false) |
|
|
|
immediate: true |
|
|
|
// true表示深度侦听,侦听对象属性的变化 |
|
|
|
// deep: true |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getEnergyBoardFn() { |
|
|
|
getEnergyBoardAPi().then(res => { |
|
|
|
console.log('地图首页情报板点位', res) |
|
|
|
this.markBoardDataList = res |
|
|
|
this.initAMap() |
|
|
|
}) |
|
|
|
}, |
|
|
|
initAMap() { |
|
|
@ -351,7 +364,7 @@ export default { |
|
|
|
// 创建一个 Marker 实例:创建点标记 |
|
|
|
let marker = new AMap.Marker({ |
|
|
|
position: new AMap.LngLat(...item.lnp.split(',')), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9] |
|
|
|
offset: new AMap.Pixel(0, 0), |
|
|
|
offset: new AMap.Pixel(-25, -50), |
|
|
|
title: item.deviceName, |
|
|
|
map: this.map, |
|
|
|
extData: item, |
|
|
@ -364,7 +377,7 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
marker.setLabel({ |
|
|
|
offset: new AMap.Pixel(0, 10), // 设置文本标注偏移量 |
|
|
|
offset: new AMap.Pixel(0, 0), // 设置文本标注偏移量 |
|
|
|
content: '', // 设置文本标注内容 |
|
|
|
// content: "<div style='padding:1vh 1vw;background-color:rgba(0,0,0,0);border:0;font-size:19px;color:rgba(188, 218, 250, 1);'>" + item.tit + '</div>', // 设置文本标注内容 |
|
|
|
direction: 'top' // 设置文本标注方位 |
|
|
|