|
|
@ -116,38 +116,48 @@ export default { |
|
|
|
methods: { |
|
|
|
...mapActions({ |
|
|
|
set_qyjj: 'SET_QYJJ', |
|
|
|
set_garden: 'SET_GARDEN', |
|
|
|
}), |
|
|
|
async switcMapType(type) { |
|
|
|
switcMapType: function (type) { |
|
|
|
if (this.debounceTimer) { |
|
|
|
clearTimeout(this.debounceTimer); |
|
|
|
} |
|
|
|
|
|
|
|
this.debounceTimer = setTimeout(async () => { |
|
|
|
if (type === 'Emap') { |
|
|
|
this.mapType = null; |
|
|
|
this.mapFlag = 'Emap'; |
|
|
|
scene.destroy(); |
|
|
|
myMap = null; |
|
|
|
return; |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.mapFlag = 'Amap'; |
|
|
|
if (!myMap) { |
|
|
|
await new Promise(resolve => setTimeout(resolve, 5000)); |
|
|
|
await this.init(type); |
|
|
|
} else { |
|
|
|
if (polygonLayer) { |
|
|
|
scene.removeLayer(polygonLayer); |
|
|
|
} |
|
|
|
this.initPolygonLayer(type); |
|
|
|
|
|
|
|
if (type === 'unit') { |
|
|
|
this.initDot(point); |
|
|
|
} else { |
|
|
|
this.removeDotLayers(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
removeDotLayers() { |
|
|
|
if (dotTextLayer || dotLayer) { |
|
|
|
scene.removeLayer(dotTextLayer); |
|
|
|
scene.removeLayer(dotLayer); |
|
|
|
} |
|
|
|
}, 1000); // 设置防抖间隔,这里是1秒 |
|
|
|
}, |
|
|
|
// switcMapType: debounce( |
|
|
|
// async function (type) { |
|
|
|
// console.log(type); |
|
|
|
// if (type === 'Emap') { |
|
|
|
// this.mapType = null; |
|
|
|
// this.mapFlag = 'Emap'; |
|
|
|
// scene.destroy(); |
|
|
|
// myMap = null; |
|
|
|
// return; |
|
|
|
// } |
|
|
|
// this.mapFlag = 'Amap'; |
|
|
|
// if (!myMap) { |
|
|
|
// await new Promise(resolve => setTimeout(resolve, 5000)); |
|
|
|
// await this.init(type); |
|
|
|
// } else { |
|
|
|
// this.initPolygonLayer(type); |
|
|
|
// } |
|
|
|
// }, 2000), |
|
|
|
toProvince() { |
|
|
|
this.mapFlag = 'Amap' |
|
|
|
setTimeout(() => { |
|
|
@ -178,15 +188,12 @@ export default { |
|
|
|
logoVisible: false, |
|
|
|
map: myMap, |
|
|
|
}); |
|
|
|
scene.addImage("textBg", require("@/assets/images/map/textBg.png")); |
|
|
|
scene.on("loaded", () => { |
|
|
|
if (!type) { |
|
|
|
this.initCircle() |
|
|
|
} else if (type == 'unit') { |
|
|
|
this.initPolygonLayer() |
|
|
|
} else if (type == 'resource') { |
|
|
|
} else if (type == 'unit' || type == 'resource' || type == 'szyf' || type == 'garden') { |
|
|
|
this.initPolygonLayer(type) |
|
|
|
}else if (type == 'szyf') { |
|
|
|
this.initFlow(type) |
|
|
|
} |
|
|
|
}); |
|
|
|
scene.on("click", (feature) => { |
|
|
@ -196,7 +203,7 @@ export default { |
|
|
|
initCircle() { |
|
|
|
circleLayerSmall = new ImageLayer({}); |
|
|
|
circleLayerSmall.source( |
|
|
|
`${process.env.VUE_APP_MAP_IMG}circle1.png`, |
|
|
|
`https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/yifeng/2024-02-03/circle.png`, |
|
|
|
{ |
|
|
|
parser: { |
|
|
|
type: 'image', |
|
|
@ -218,7 +225,7 @@ export default { |
|
|
|
scene.setZoom(10) |
|
|
|
roadLayer = new ImageLayer({}); |
|
|
|
roadLayer.source( |
|
|
|
`${process.env.VUE_APP_MAP_IMG}road1.png`, |
|
|
|
`https://elink-esua-epdc.oss-cn-qingdao.aliyuncs.com/epmet/yifeng/2024-02-03/road.png`, |
|
|
|
{ |
|
|
|
parser: { |
|
|
|
type: 'image', |
|
|
@ -266,7 +273,6 @@ export default { |
|
|
|
} |
|
|
|
if (textLayer) { |
|
|
|
scene.removeLayer(textLayer); |
|
|
|
|
|
|
|
} |
|
|
|
if (type == 'szyf') { |
|
|
|
this.initFlow() |
|
|
@ -343,15 +349,22 @@ export default { |
|
|
|
}) |
|
|
|
.active(true); |
|
|
|
scene.addLayer(textLayer); |
|
|
|
let _this = this |
|
|
|
let filteredPoint = { ...point }; // 或者使用其他对象深拷贝方法 |
|
|
|
filteredPoint.features = filteredPoint.features.filter(item => item.properties.category === type); |
|
|
|
if (type === 'unit' || type === 'garden') { |
|
|
|
this.initDot(filteredPoint, type); |
|
|
|
} |
|
|
|
polygonLayer.on("click", (e) => { |
|
|
|
|
|
|
|
}); |
|
|
|
}, |
|
|
|
initDot(data) { |
|
|
|
console.log(data, '点位数据'); |
|
|
|
scene.addImage("dotBto", require("@/assets/images/map/dot.png")); |
|
|
|
scene.addImage("textBg", require("@/assets/images/map/textBg.png")); |
|
|
|
initDot(data, type) { |
|
|
|
if (dotTextLayer) { |
|
|
|
scene.removeLayer(dotTextLayer); |
|
|
|
} |
|
|
|
if (dotLayer) { |
|
|
|
scene.removeLayer(dotLayer); |
|
|
|
} |
|
|
|
//textOffset改为动态的 this.buttonIndex == 3 [10,60] 否则就是 [-30 60] |
|
|
|
dotTextLayer = new PointLayer({ |
|
|
|
zIndex: 21, |
|
|
@ -386,7 +399,19 @@ export default { |
|
|
|
scene.addLayer(dotLayer); |
|
|
|
let that = this |
|
|
|
dotTextLayer.on("click", (e) => { |
|
|
|
if (type == 'unit') { |
|
|
|
if (e.feature.properties.id === '2') { |
|
|
|
that.set_qyjj(true) |
|
|
|
} else { |
|
|
|
this.$message.error('暂无数据~'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (e.feature.properties.id === '3') { |
|
|
|
that.set_garden(true) |
|
|
|
} else { |
|
|
|
this.$message.error('暂无数据~'); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// dotTextLayer.on("mousemove", (e) => { |
|
|
@ -409,6 +434,12 @@ export default { |
|
|
|
computed: { |
|
|
|
...mapGetters(['navId',]), |
|
|
|
}, |
|
|
|
beforeDestroy() { |
|
|
|
if (myMap) { |
|
|
|
scene.destroy(); |
|
|
|
myMap = null |
|
|
|
} |
|
|
|
}, |
|
|
|
watch: {}, |
|
|
|
} |
|
|
|
</script> |
|
|
|