From 3adf551beb05f30fe8ce8dd6ece68d078b215fd8 Mon Sep 17 00:00:00 2001 From: lin <648540858@qq.com> Date: Thu, 23 Oct 2025 22:49:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E6=A0=87=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/common/MapComponent.vue | 41 ++++++++++++++------------- web/src/views/map/index.vue | 6 ++++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/web/src/views/common/MapComponent.vue b/web/src/views/common/MapComponent.vue index 2713b7201..9d62362c2 100755 --- a/web/src/views/common/MapComponent.vue +++ b/web/src/views/common/MapComponent.vue @@ -296,8 +296,7 @@ export default { feature.setId(data[i].id) feature.customData = data[i].data feature.setProperties({ - status: 'offline', - iconSrc: 'static/images/gis/camera1-offline.png' + status: data[i].status, }) // const style = new Style() // style.setImage(new Icon({ @@ -321,17 +320,23 @@ export default { // 'circle-fill-color': 'red', // 'circle-stroke-color': 'white', // 'circle-stroke-width': 0.5 - 'icon-src': 'static/images/gis/camera1.png', - // 'icon-src': [ - // 'case', - // ['==', ['get', 'status'], 'online'], 'static/images/gis/camera1.png', - // ['==', ['get', 'status'], 'offline'], 'static/images/gis/camera1-offline.png', - // ['==', ['get', 'status'], 'checked'], 'static/images/gis/camera1-red.png', - // 'static/images/gis/camera1.png' - // ], - // 'icon-src': ['get', 'iconSrc'], - 'icon-width': 40, - 'icon-height': 40 + 'icon-src': 'static/images/gis/sprite.png', + 'icon-width': 120, + 'icon-height': 40, + 'icon-size': [40, 40], + 'icon-anchor': [0.5, 1], + 'icon-offset-origin': 'bottom-left', + 'icon-offset': [ + 'match', + ['get', 'status'], + 'ON', + [0, 0], + 'OFF', + [40, 0], + 'checked', + [80, 0], + [120, 60] + ] } }) if (clickEvent && typeof clickEvent === 'function') { @@ -473,13 +478,9 @@ export default { const feature = new Feature(new Point(fromLonLat(data.position))) feature.setId(data.id) feature.customData = data.data - const style = new Style() - style.setImage(new Icon({ - anchor: data.image.anchor, - crossOrigin: 'Anonymous', - src: data.image.src - })) - feature.setStyle(style) + feature.setProperties({ + status: data.status + }) layer.getSource().addFeature(feature) }, diff --git a/web/src/views/map/index.vue b/web/src/views/map/index.vue index 2857fcc46..03170ab70 100755 --- a/web/src/views/map/index.vue +++ b/web/src/views/map/index.vue @@ -246,6 +246,7 @@ export default { id: data.gbId, position: position, data: data, + status: data.gbStatus, image: { anchor: [0.5, 1], src: this.getImageByChannel(data) @@ -290,6 +291,7 @@ export default { let cameraData = { id: item.gbId, position: position, + status: item.gbStatus, data: item, image: { anchor: [0.5, 1], @@ -465,6 +467,7 @@ export default { id: channel.gbId, position: position, data: channel, + status: 'checked', image: { anchor: [0.5, 1], src: 'static/images/gis/camera1-red.png' @@ -485,6 +488,7 @@ export default { id: channel.gbId, position: [channel.gbLongitude, channel.gbLatitude], data: channel, + status: channel.gbStatus, image: { anchor: [0.5, 1], src: this.getImageByChannel(channel) @@ -506,6 +510,7 @@ export default { id: channel.gbId, position: position, data: channel, + status: channel.gbStatus, image: { anchor: [0.5, 1], src: this.getImageByChannel(channel) @@ -766,6 +771,7 @@ export default { id: item.gbId, position: position, data: item, + status: item.gbStatus, image: { anchor: [0.5, 1], src: this.getImageByChannel(item)