<!-- * @Description: 重点用户分布 * @Author: 王晓颖 * @Date: 2021-04-11 --> <template> <layout-map> <!--统计结果显示--> <div class="label-div"> <div class="label"> {{ boardData.name }} </div> <div class="value"> {{ boardData.value }} </div> </div> <!--地图--> <Map :url="configUrl" @onload="onMapload" /> </layout-map> </template> <script> import 'mars3d-echarts' import Map from '@/components/Map/MarsMap.vue' import Weather from '@/components/weather/weather' import Clock from '@/components/clock/Clock' import Brand from '@/components/Brand/brand' import LayoutMap from '@/layout/layoutMap' import { getUserSupply } from '@/api/needSupply' import { getToday } from '@/utils/dateutils' export default { name: 'Vip', components: { LayoutMap, Weather, Clock, Map, Brand }, filters: { boardNameFilter(val) { if (val === '全部' || val === '') { return '全省重点用户' } else { return val + '区域重点用户' } } }, data() { return { map: null, // 地图 configUrl: 'static/config/config.json', alpha: 100, // 透明度 underground: null, // ? positionShow: true, // 显示位置 boardData: { name: '重点用户', value: 16 }, // 统计版展示数据 vipList: [], // 重点用户点位 vipLayer: null, // 重点用户分布图层 pointColorArr: ['#f33349', '#f79a2c', '#95e40c', '#95e40c', '#1ffee6'], graphicLayer: null, // 管理站标签图层 timer: null, // 定时器 clock: 86400 // 1小时定时刷新 } }, methods: { // 地图构造完成回调 onMapload(map) { // 以下为演示代码 this.map = map // 背景透明 this.map._viewer.scene.backgroundColor = new this.Cesium.Color(0.0, 0.0, 0.0, 0.0) this.map._viewer.scene.globe.baseColor.alpha = 0 // 添加重点用户隐患点 this.addVipPosition() }, // 重点用户位置 addVipPosition() { const date = getToday() getUserSupply(date).then(res => { const data = res.data.map(item => { return { name: item['WD02_03'], x: parseFloat(item['WD02_04']), y: parseFloat(item['WD02_05']), pngSupply: item['DL03'], lngSupply: item['DL02'], supply: item['DL03'] + item['DL02'], need: item['DL03'] + item['DL02'] } }) this.vipList = data this.addFeatures(this.vipList) }) // getUserNeedSupply().then(res => { // if (res.code === 200) { // this.vipList = res.data // this.addFeatures(this.vipList) // } // }) }, // 添加用户点位 addFeatures(arr) { const { mars3d, Cesium } = this // 创建DIV数据图层 if (this.vipLayer) { this.map.removeLayer(this.vipLayer) } var graphicLayer = new mars3d.layer.DivLayer() this.vipLayer = graphicLayer this.map.addLayer(graphicLayer) // 在layer上绑定监听事件 graphicLayer.on(mars3d.EventType.click, function(event) { console.log('监听layer,单击了矢量对象', event) }) graphicLayer.bindPopup(function(event) { const item = event.graphic.attr var html = ` <div class="popup-win"><span class="title">${item.name}</span><br/> <span style="color:#63AEFF">需求:${item.need} m³</span><br/> <span style="color:#FFB861">供应:${item.supply}m³</span><br/> <span style="color:#FFB861">png供应:${item.pngSupply}m³</span><br/> <span style="color:#FFB861">lng供应:${item.lngSupply}m³</span></div>` return html }) // 遍历显示图标 for (const item of arr) { var jd = item.x var wd = item.y var clr = this.pointColorArr[2] var graphic = new mars3d.graphic.DivGraphic({ position: Cesium.Cartesian3.fromDegrees(jd, wd, 0), style: { html: '<div class="mars3d-animation-point" style="color:' + clr + ';"><p></p></div>', distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 2000000) // 按视距距离显示 }, attr: item }) graphicLayer.addGraphic(graphic) } }, // 打开轮询,定时刷新数据 refreshData() { this.timer = setInterval(() => { console.log('refreshData') if (this.vipLayer) { this.addVipPosition() } }, this.clock * 1000) } } } </script> <style rel="stylesheet/scss" lang="scss" scoped> .label-div{ position: absolute; top: 140px; left:31rem; z-index:100; color: white; padding:2rem 3rem 1.5rem 3rem; background-image: url("../../assets/button_images/board-box1.png"); background-size: 100% 100%; .label{ margin-bottom: 1rem; font-size:1.2rem; } .value{ font-family: DS-DigitalBold; font-size:2.5rem; } } .map-btn-group{ position: absolute; bottom:3rem; left:50%; transform: translateX(-50%); display: flex; justify-content: center; } </style> <style rel="stylesheet/scss" lang="scss"> /*整个容器*/ .mapcontainer { position: relative; height: 100%; width: 100%; background-color: transparent; /*background-color: #051151;*/ } </style>