diff --git a/src/views/contentData/LeftSidebar/index.vue b/src/views/contentData/LeftSidebar/index.vue index 88ce87d..93ecdd6 100644 --- a/src/views/contentData/LeftSidebar/index.vue +++ b/src/views/contentData/LeftSidebar/index.vue @@ -373,7 +373,6 @@ export default { if (existingTimer) { clearInterval(existingTimer); // 清除旧计时器 } - console.log(this.lonAndLat, "this.lonAndLat"); // 设置15秒初始时间 newItem.currTime = window.mapConfig.currTime; // 创建新计时器 @@ -531,7 +530,6 @@ export default { } }, closeNavigation(drone) { - console.log(drone.app_lat, drone.app_lon, "导航"); // 确保 drone.app_lon 和 drone.app_lat 存在 if (!drone || !drone.app_lon || !drone.app_lat) { this.$message.error("无人机的经纬度信息无效"); @@ -574,7 +572,6 @@ export default { const naviUrl = `https://uri.amap.com/navigation?to=${ drone.app_lon + "," + drone.app_lat },飞手位置&callnative=1`; - console.log(naviUrl, "naviUrl"); try { // 异步生成二维码并存储到 qrCodes 对象 const qrCodeDataUrl = await QRCode.toDataURL(naviUrl, { @@ -660,6 +657,7 @@ export default { return setInterval(() => { if (item.currTime > 0) { item.currTime--; + console.log(item.currTime, "item.currTime"); // 更新显示时间(可选) const index = this.drones.findIndex( (d) => d.BatchId === item.BatchId @@ -806,7 +804,7 @@ export default { const trackStyleljx = new Style({ stroke: new Stroke({ color: this.getRandomColor(), - width: 2, + width: 5, lineDash: [4, 4], zIndex: 1 }) @@ -828,9 +826,12 @@ export default { getRandomColor() { const letters = "0123456789ABCDEF"; let color = "#"; - for (let i = 0; i < 6; i++) { - color += letters[Math.floor(Math.random() * 16)]; - } + color += "0"; + color += letters[Math.floor(Math.random() * 4)]; + color += letters[Math.floor(Math.random() * 16)]; + color += letters[Math.floor(Math.random() * 16)]; + color += letters[Math.floor(Math.random() * 16)]; + color += letters[Math.floor(Math.random() * 16)]; return color; } } diff --git a/src/views/contentData/index.js b/src/views/contentData/index.js index fed1902..c1005fb 100644 --- a/src/views/contentData/index.js +++ b/src/views/contentData/index.js @@ -434,7 +434,14 @@ export function mapUavFiex(options, map) { name: "无人机轨迹" }); track.setId(item.BatchId + "_track"); - + track.setStyle( + new Style({ + stroke: new Stroke({ + color: getRandomColor(), // 线条颜色(可自定义) + width: 5 // 线条宽度(调整此值以控制粗细,单位为像素) + }) + }) + ); graphicLayer.getSource().addFeature(graphic); graphicLayerGJ.getSource().addFeature(track); // graphicLayerGJ.setStyle(null); @@ -526,3 +533,16 @@ export function mapUavFiex(options, map) { }); } } + +// 随机颜色生成函数 +function getRandomColor() { + const letters = "0123456789ABCDEF"; + let color = "#"; + color += "0"; + color += letters[Math.floor(Math.random() * 4)]; + color += letters[Math.floor(Math.random() * 16)]; + color += letters[Math.floor(Math.random() * 16)]; + color += letters[Math.floor(Math.random() * 16)]; + color += letters[Math.floor(Math.random() * 16)]; + return color; +}