diff --git a/src/views/map/index.vue b/src/views/map/index.vue index d2b4712..2e5b981 100644 --- a/src/views/map/index.vue +++ b/src/views/map/index.vue @@ -93,11 +93,11 @@ :corp-info-id="CORP_INFO_ID" :area="area" :gangkou="gangkouActive"/> - + + + + +
- - + + 搜索 重置 @@ -326,6 +326,8 @@ var PI = 3.1415926535897932384626 var a = 6378245.0 // 卫星椭球坐标投影到平面地图坐标系的投影因子。 var ee = 0.00669342162296594323 // 椭球的偏心率。//判断是否在国内,在中国国内的经纬度才需要做偏移 const iframeObj = null +const mqttPoint = {} +let trajectoryEntityCollection = {} export default { components: { AnquanCfd, @@ -478,7 +480,7 @@ export default { ], myEntityCollection: {}, poinEntity: {}, - mqttPoint: {}, + // mqttPoint: {}, allOrientationPoint: [], gangkouActive: '', centerOptionsList: [ @@ -1247,7 +1249,7 @@ export default { linkPort: '8093', VIIDPort: '8088' }, - trajectoryEntityCollection: {}, + // trajectoryEntityCollection: {}, isPeopleTrajectory: false, peopleTrajectoryValue: '' } @@ -1555,24 +1557,24 @@ export default { document.addEventListener('contextmenu', function(event) { event.preventDefault() }) - // this.handler.setInputAction(movement => { - // const pick = viewer.scene.pick(movement.position) - // if (Cesium.defined(pick) && (pick.id.id)) { - // if (!pick.id._monitoItems) { - // this.removeTrajectory() - // return - // } - // const point_type = pick.id._monitoItems.data.point_type - // const point_id = pick.id._monitoItems.data.id - // const corpInfoId = pick.id._monitoItems.data.corpInfoId - // if (point_type === '标记点peoplePositionOne') { - // this.removeTrajectory() - // this.addTrajectory(point_id, corpInfoId) - // } - // } else { - // this.removeTrajectory() - // } - // }, Cesium.ScreenSpaceEventType.RIGHT_CLICK) + // this.handler.setInputAction(movement => { + // const pick = viewer.scene.pick(movement.position) + // if (Cesium.defined(pick) && (pick.id.id)) { + // if (!pick.id._monitoItems) { + // this.removeTrajectory() + // return + // } + // const point_type = pick.id._monitoItems.data.point_type + // const point_id = pick.id._monitoItems.data.id + // const corpInfoId = pick.id._monitoItems.data.corpInfoId + // if (point_type === '标记点peoplePositionOne') { + // this.removeTrajectory() + // this.addTrajectory(point_id, corpInfoId) + // } + // } else { + // this.removeTrajectory() + // } + // }, Cesium.ScreenSpaceEventType.RIGHT_CLICK) }, addTrajectory() { this.removeTrajectory() @@ -1595,14 +1597,14 @@ export default { const collection = new Cesium.CustomDataSource('trajectoryEntityCollection') collection.entities.add(entity) viewer.dataSources.add(collection) - this.trajectoryEntityCollection = collection + trajectoryEntityCollection = collection } }) }, removeTrajectory() { - if (Object.keys(this.trajectoryEntityCollection).length === 0) return - viewer.dataSources.remove(this.trajectoryEntityCollection) - this.trajectoryEntityCollection = {} + if (Object.keys(trajectoryEntityCollection).length === 0) return + viewer.dataSources.remove(trajectoryEntityCollection) + trajectoryEntityCollection = {} }, getCatesian3FromPX: function(px) { @@ -1677,11 +1679,11 @@ export default { transformWGS84ToCartesian: function(position, alt) { // eslint-disable-next-line no-return-assign return position ? Cesium.Cartesian3.fromDegrees( - position.lng || position.lon, - position.lat, - position.alt = alt || position.alt, - Cesium.Ellipsoid.WGS84 - ) + position.lng || position.lon, + position.lat, + position.alt = alt || position.alt, + Cesium.Ellipsoid.WGS84 + ) : Cesium.Cartesian3.ZERO }, closeBubbles() { @@ -2361,7 +2363,7 @@ export default { } else { ry_drag.addEntity(this.perLocArr[i]) - this.mqttPoint['cfdrydw' + this.perLocArr[i].cardNo] = this.perLocArr[i].cardNo + mqttPoint['cfdrydw' + this.perLocArr[i].cardNo] = this.perLocArr[i].cardNo } } }, @@ -2715,7 +2717,7 @@ export default { czksPerLoc.push(perLoc) ry_drag.addEntity(perLoc) var qianzhui = 'czksperson' - _this.mqttPoint[qianzhui + item.cardId] = item.cardId + mqttPoint[qianzhui + item.cardId] = item.cardId } } // 最后更新ninePerLocArr @@ -2788,7 +2790,7 @@ export default { } this.onePerLocArr.push(perLoc) ry_drag.addEntity(perLoc) - this.mqttPoint[this.subscription.topic.substring(0, this.subscription.topic.lastIndexOf('+')) + item.deviceCode] = item.deviceCode + mqttPoint[this.subscription.topic.substring(0, this.subscription.topic.lastIndexOf('+')) + item.deviceCode] = item.deviceCode } } } else if (topic.indexOf('alarm') !== -1) { @@ -2803,20 +2805,20 @@ export default { }) }, clearMqttPoint(prefix) { - for (const mqttPointKey in this.mqttPoint) { - const key = prefix ? prefix + this.mqttPoint[mqttPointKey] : mqttPointKey - viewer.entities.removeById(this.mqttPoint[key]) - this.onePerLocArr = this.onePerLocArr.filter(item => item.data_id !== this.mqttPoint[key]) - delete this.mqttPoint[key] + for (const mqttPointKey in mqttPoint) { + const key = prefix ? prefix + mqttPoint[mqttPointKey] : mqttPointKey + viewer.entities.removeById(mqttPoint[key]) + this.onePerLocArr = this.onePerLocArr.filter(item => item.data_id !== mqttPoint[key]) + delete mqttPoint[key] } }, clearRYDWPoint(prefix) { this.fwebsocket.close() - for (const mqttPointKey in this.mqttPoint) { - const key = prefix ? prefix + this.mqttPoint[mqttPointKey] : mqttPointKey - viewer.entities.removeById(this.mqttPoint[key]) - this.onePerLocArr = this.onePerLocArr.filter(item => item.data_id !== this.mqttPoint[key]) - delete this.mqttPoint[key] + for (const mqttPointKey in mqttPoint) { + const key = prefix ? prefix + mqttPoint[mqttPointKey] : mqttPointKey + viewer.entities.removeById(mqttPoint[key]) + this.onePerLocArr = this.onePerLocArr.filter(item => item.data_id !== mqttPoint[key]) + delete mqttPoint[key] } }, // 删除人员定位点 @@ -2999,8 +3001,9 @@ export default { _this.fwebsocket = new WebSocket(encodeURI(wsUrl)) _this.fwebsocket.onmessage = function(message) { console.info('接收消息') - const peopleList = JSON.parse(message.data).data.data + const peopleList = JSON.parse(message.data) console.log(peopleList) + viewer.entities.suspendEvents() for (let i = 0; i < peopleList.length; i++) { const item = peopleList[i] if ((!item)) continue @@ -3019,6 +3022,7 @@ export default { } else { const perLoc = { id: item.id, + name: item.name, x: x, y: y, icon_type: 'img4_0' + pointColor, @@ -3029,9 +3033,10 @@ export default { } _this.onePerLocArr.push(perLoc) ry_drag.addEntity(perLoc) - _this.mqttPoint[_this.subscription.topic.substring(0, _this.subscription.topic.lastIndexOf('+')) + item.id] = item.id + mqttPoint[_this.subscription.topic.substring(0, _this.subscription.topic.lastIndexOf('+')) + item.id] = item.id } } + viewer.entities.resumeEvents() } } }, @@ -3067,12 +3072,12 @@ export default { if (decodedStr) { // const perTrack = JSON.parse(decodedStr) const perTrack = { 'msg': '000', 'data': [ - '8905,118.50022313549867,38.92716921306408,-88.96163116878053,0.15,8905,测试工单', - '8001,118.5044033058593,38.926660124965956,-88.96163116878053,0.15,8001,张悦', - '8002,118.48886198164132,38.916885738277635,-88.96163116878053,0.15,8002,齐津铖', - '8003,118.50289308906841,38.92012841170512,-88.96163116878053,0.15,8003,白伟', - '8004,118.48820877892216,38.91690951376236,-88.96163116878053,0.15,8004,孙海官' - ] } + '8905,118.50022313549867,38.92716921306408,-88.96163116878053,0.15,8905,测试工单', + '8001,118.5044033058593,38.926660124965956,-88.96163116878053,0.15,8001,张悦', + '8002,118.48886198164132,38.916885738277635,-88.96163116878053,0.15,8002,齐津铖', + '8003,118.50289308906841,38.92012841170512,-88.96163116878053,0.15,8003,白伟', + '8004,118.48820877892216,38.91690951376236,-88.96163116878053,0.15,8004,孙海官' + ] } if (perTrack.msg === '000' && perTrack.data && perTrack.data.length > 0) { perTrack.data.forEach(item => { const newPos = item.split(',') @@ -3743,38 +3748,38 @@ export default { transform: translateY(0); } } - .people_trajectory{ - position: absolute; - top: -60px; - left: 0; - width: 400px; - padding: 10px; - background-image: linear-gradient(to right, rgb(31 62 129 / 57%) 0%, rgb(17 93 255 / 40%) 50%, rgb(31 62 129 / 57%) 100%); - .search_btn{ - background-color: #1563e3; - color: #fff; - border-color: #1563e3; - } - .reset_btn{ - background-color: #558be5; - color: #fff; - border-color: #558be5; - } +.people_trajectory{ + position: absolute; + top: -60px; + left: 0; + width: 400px; + padding: 10px; + background-image: linear-gradient(to right, rgb(31 62 129 / 57%) 0%, rgb(17 93 255 / 40%) 50%, rgb(31 62 129 / 57%) 100%); + .search_btn{ + background-color: #1563e3; + color: #fff; + border-color: #1563e3; } + .reset_btn{ + background-color: #558be5; + color: #fff; + border-color: #558be5; + } +}