From b9a58b24e011f5f2cfabe1fd999371b99ad6622b Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Thu, 24 Apr 2025 15:57:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E5=AD=90=E7=9C=8B=E6=9D=BF=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=90=AD=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../css/synthesisQuery/digitalSignage.css | 138 ++++- .../js/synthesisQuery/digitalSignage.js | 503 +++++++++++++++++- .../pages/synthesisQuery/digitalSignage.html | 30 ++ 3 files changed, 662 insertions(+), 9 deletions(-) diff --git a/src/main/resources/static/css/synthesisQuery/digitalSignage.css b/src/main/resources/static/css/synthesisQuery/digitalSignage.css index adc6b1c..2345732 100644 --- a/src/main/resources/static/css/synthesisQuery/digitalSignage.css +++ b/src/main/resources/static/css/synthesisQuery/digitalSignage.css @@ -42,7 +42,8 @@ body { } .scroll-box, -.legend-box { +.legend-box, +.right-drawer-box { position: absolute; background: rgba(0, 0, 0, 0.5); color: #fff; @@ -136,3 +137,138 @@ body { width: 18px; height: 18px; } + +.map-container { + background: rgba(0, 0, 0, 0.5); + color: white; + padding: 10px; + border-radius: 4px; + box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.3); + /* min-width: 150px; */ + font-family: Arial, sans-serif; +} + +.map-container h4 { + margin: 0 0 8px 0; + font-size: 16px; + border-bottom: 1px solid rgba(255, 255, 255, 0.2); + padding-bottom: 5px; +} + +.map-container-item { + padding: 4px 6px; + display: flex; + align-items: center; + justify-content: space-between; + font-size: 14px; +} + +.map-container-item span:first-child { + width: 160px; +} +.map-container-item span:last-child { + min-width: 120px; + text-align: right; +} + +/* 索道信息窗口样式 */ +.map-container-item-ropeway span:first-child { + padding-left: 16px; +} +.map-container-item-ropeway span:last-child { + margin-left: 4px; + min-width: 120px; +} + +/* 交叉信息窗口样式 */ +.map-container-cross { + display: flex; +} +.map-container-cross .map-container-1 { + width: 260px; + padding: 10px; + border-radius: 0; + border-top-left-radius: 4px; + border-bottom-left-radius: 4px; + box-shadow: none; +} +.map-container-cross .map-container-2 { + width: 220px; + padding: 10px; + border-radius: 0; + border-top-right-radius: 4px; + border-bottom-right-radius: 4px; + box-shadow: none; +} + +.map-container-cross .map-container-2 h4 { + padding-left: 20px; +} + +/* 右侧抽屉 */ +.right-drawer-box { + top: 50%; + right: 0; + width: 400px; + height: 90%; + transform: translateY(-50%); + display: none; + box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1); + transition: right 0.3s ease-in-out; +} + +/* 打开弹框的三角 */ +.open-drawer-box { + position: absolute; + top: 50%; + right: 0; + transform: translateY(-50%); + width: 0; + height: 0; + border-style: solid; + border-width: 20px 20px 20px 0; + border-color: transparent #d7d7d7 transparent transparent; + z-index: 999; + cursor: pointer; +} + +.close-drawer-btn { + position: absolute; + top: 50%; + left: 0; + transform: translateY(-50%); + width: 0; + height: 0; + border-style: solid; + border-width: 20px 0px 20px 20px; + border-color: transparent transparent transparent #d7d7d7; + z-index: 999; + cursor: pointer; +} + +/* 当抽屉打开时,隐藏三角按钮 */ +.right-drawer-box.open ~ .open-drawer-box { + display: none; +} + +.open { + display: block; +} + +.organization-tree-box { + padding: 20px; + height: calc(100% - 40px); + overflow-y: auto; +} + +.layui-tree-txt { + color: #fff !important; +} + +.layui-tree-icon .layui-icon { + color: #fff !important; +} + +.layui-tree-line .layui-tree-entry:hover .layui-tree-txt { + color: #dfd8d8 !important; +} diff --git a/src/main/resources/static/js/synthesisQuery/digitalSignage.js b/src/main/resources/static/js/synthesisQuery/digitalSignage.js index b7ec05b..8513b69 100644 --- a/src/main/resources/static/js/synthesisQuery/digitalSignage.js +++ b/src/main/resources/static/js/synthesisQuery/digitalSignage.js @@ -1,6 +1,405 @@ -const map = new BMapGL.Map("map-box"); // 创建Map实例 -map.centerAndZoom(new BMapGL.Point(116.404, 39.915), 11); // 初始化地图,设置中心点坐标和地图级别 -map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放 +let map = null; + +// 地图配置项 +const config = { + points: [ + { + lng: 116.254, // 向西偏移 + lat: 39.965, // 向北偏移 + title: "点1", + type: 1, + isCompleted: true, // 是否完成 + isCrossing: false, // 是否跨越 + }, + { + lng: 116.263, // 保持适当距离 + lat: 39.972, + title: "点2", + type: 1, + isCompleted: true, // 是否完成 + isCrossing: false, // 是否跨越 + }, + { + lng: 116.275, // 平滑过渡 + lat: 39.958, + title: "点3", + type: 1, + isCompleted: true, // 是否完成 + isCrossing: false, // 是否跨越 + }, + { + lng: 116.285, // 继续向东 + lat: 39.945, + title: "点4", + type: 2, + isCompleted: true, // 是否完成 + isCrossing: false, // 是否跨越 + }, + { + lng: 116.298, // 向南偏移 + lat: 39.935, + title: "点5", + type: 2, + isCompleted: false, // 是否完成 + isCrossing: false, // 是否跨越 + }, + { + lng: 116.305, // 保持连贯性 + lat: 39.925, + title: "点6", + type: 2, + isCompleted: false, // 是否完成 + isCrossing: false, // 是否跨越 + }, + { + lng: 116.315, // 最终点 + lat: 39.915, + title: "点7", + type: 3, + isCompleted: false, // 是否完成 + isCrossing: true, // 是否跨越 + }, + { + lng: 116.325, // 最远点 + lat: 39.905, + title: "点8", + type: 9, + isCompleted: false, // 是否完成 + isCrossing: true, // 是否跨越 + }, + ], + polyline: { + strokeColor: "#3388ff", // 线条颜色 + strokeWeight: 3, // 线条宽度 + strokeOpacity: 0.8, // 透明度 + strokeStyle: "dashed", // solid(实线)或dashed(虚线) + enableEditing: false, // 是否可编辑 + enableClicking: true, // 是否可点击 + }, +}; + +// 百度地图初始化 +function initMap() { + map = new BMapGL.Map("map-box"); + // 以第一个点为中心初始化地图 + map.centerAndZoom( + new BMapGL.Point(config.points[0].lng, config.points[0].lat), + 11 + ); + map.enableScrollWheelZoom(true); + + map.setMapStyleV2({ + // styleJson: [ + // { + // featureType: "background", + // elementType: "geometry", + // stylers: { + // color: "#f5f5f5", // 浅灰色背景 + // }, + // }, + // { + // featureType: "road", + // elementType: "geometry", + // stylers: { + // visibility: "off", // 隐藏道路 + // }, + // }, + // ], + }); + // map.setMapType(BMAP_EARTH_MAP); // 地球模式 + // map.setDisplayOptions({ + // poiText: false, // 隐藏POI文字 + // poiIcon: false, // 隐藏POI图标 + // building: false, // 隐藏建筑物 + // }); + + // 添加地图控件(可选) + // map.addControl(new BMapGL.NavigationControl()); + // map.addControl(new BMapGL.ScaleControl()); + + // 地图加载完成后添加标点和折线 + map.addEventListener("tilesloaded", function () { + addAllMapPoints(); + addMapLine(); + }); +} + +// 添加标点 +function addAllMapPoints() { + // 清除地图上所有现有的标记 + map.clearOverlays(); + + const bounds = []; + const iconTypeList = { + 1: "/gzDigitalSignage/img/digitalSignage/yellow.png", + 2: "/gzDigitalSignage/img/digitalSignage/green.png", + 3: "/gzDigitalSignage/img/digitalSignage/blue.png", + 4: "/gzDigitalSignage/img/digitalSignage/orange.png", + 5: "/gzDigitalSignage/img/digitalSignage/zt_red.png", + 6: "/gzDigitalSignage/img/digitalSignage/zt_purple.png", + 7: "/gzDigitalSignage/img/digitalSignage/zt_green.png", + 8: "/gzDigitalSignage/img/digitalSignage/white.png", + 9: "/gzDigitalSignage/img/digitalSignage/sd.png", + }; + + // 使用对象记录已添加的点,避免重复 + const addedPoints = {}; + + config.points.forEach((pointData, index) => { + const pointKey = `${pointData.lng},${pointData.lat}`; + + // 如果该坐标点已经添加过标记,则跳过 + if (addedPoints[pointKey]) { + console.warn(`重复的点坐标被跳过: ${pointKey}`); + return; + } + + addedPoints[pointKey] = true; + const point = new BMapGL.Point(pointData.lng, pointData.lat); + bounds.push(point); + + // 检查图标是否存在,不存在则使用默认图标 + const iconUrl = iconTypeList[pointData.type] || iconTypeList[1]; // 默认使用第一个图标 + const myIcon = new BMapGL.Icon(iconUrl, new BMapGL.Size(30, 32), { + anchor: new BMapGL.Size(8, 35), // 修正锚点位置为中心底部 + imageSize: new BMapGL.Size(30, 32), // 与实际图片尺寸一致 + }); + + const marker = new BMapGL.Marker(point, { icon: myIcon }); + + // 添加信息窗口 + + let infoContent = ""; + + if (pointData.type === 9) { + // 索道 + infoContent = ` +