diff --git a/src/api/map.js b/src/api/map.js index b1ee1b5..55faac0 100644 --- a/src/api/map.js +++ b/src/api/map.js @@ -3,13 +3,13 @@ import qs from 'qs' // 渣土车辆信息数据 -export function fetchCarInfo () { - return request({ - baseURL: config.baseUrl, - url: 'car/info', - method: 'get' - }) -} +// export function fetchCarInfo () { +// return request({ +// baseURL: config.baseUrl, +// url: 'car/info', +// method: 'get' +// }) +// } export function fetchCarPostion (params) { return request({ @@ -34,7 +34,15 @@ method: 'post' }) } - +// 渣土车 +export function fetchCarInfo () { + return request({ + baseURL: config.mockUrl, + url: 'vehicleTrajectory', + data: {}, + method: 'post' + }) +} // --------------------------------------------------------------------------------------- export function fetchCommunityInfo () { return request({ diff --git a/src/api/map.js b/src/api/map.js index b1ee1b5..55faac0 100644 --- a/src/api/map.js +++ b/src/api/map.js @@ -3,13 +3,13 @@ import qs from 'qs' // 渣土车辆信息数据 -export function fetchCarInfo () { - return request({ - baseURL: config.baseUrl, - url: 'car/info', - method: 'get' - }) -} +// export function fetchCarInfo () { +// return request({ +// baseURL: config.baseUrl, +// url: 'car/info', +// method: 'get' +// }) +// } export function fetchCarPostion (params) { return request({ @@ -34,7 +34,15 @@ method: 'post' }) } - +// 渣土车 +export function fetchCarInfo () { + return request({ + baseURL: config.mockUrl, + url: 'vehicleTrajectory', + data: {}, + method: 'post' + }) +} // --------------------------------------------------------------------------------------- export function fetchCommunityInfo () { return request({ diff --git a/src/views/mapViews/mars3dMap.vue b/src/views/mapViews/mars3dMap.vue index 925a6b9..f839a80 100644 --- a/src/views/mapViews/mars3dMap.vue +++ b/src/views/mapViews/mars3dMap.vue @@ -254,16 +254,20 @@ this.layersShow[val] = true for (let i = 0; i < this.labels.length; i++) { if (i !== val) { - for (let j = 0; j < this.labels[i].layersShow.length; j++) { + for (let j = 0; j < (this.labels[i].layersShow || []).length; j++) { this.labels[i].layersShow[j] = false } } } for (let i = 0; i < this.labelsRight.length; i++) { - for (let j = 0; j < this.labelsRight[i].layersShowRight.length; j++) { + for (let j = 0; j < (this.labelsRight[i].layersShowRight || []).length; j++) { this.labelsRight[i].layersShowRight[j] = false } } + if(val === 3) { + // 获取车辆并且渲染 + this.drawCar() + } }, clickLabelRight (val) { this.layersShow = [false, false, false, false, false, false, false, false] @@ -408,6 +412,7 @@ fetchCarInfo().then(response => { if (response.code === 200) { this.data.feature = response.data + console.log(response.data, 'response.data') this.layers.feature.clear() for (let i = 0; i < this.data.feature.length; i++) { var graphic = new mars3d.graphic.ModelEntity({ @@ -415,8 +420,8 @@ position: [Number(this.data.feature[i].coordinatex), Number(this.data.feature[i].coordinatey)], style: { url: '../static/model/zhatuchelvse.gltf', - scale: 10, - minimumPixelSize: 40, + scale: 0.5, + minimumPixelSize: 25, label: { text: this.data.feature[i].vehiclenum, font_size: 18, @@ -449,31 +454,34 @@ }) }, trail: function (str) { - var val = str.split('!') - console.log(val) + // console.log(str, 'str') + // var val = str.split('!') + // console.log(val) + // console.log(str, 'str') this.map.closePopup() - const now = dateToString(new Date(), 'y-m-d-h-m-s') - const cthour = new Date() - cthour.setTime(cthour.getTime() - 3599 * 1000) - const hour = dateToString(cthour, 'y-m-d-h-m-s') - const params = { params: [val[0], hour, now] } + // const now = dateToString(new Date(), 'y-m-d-h-m-s') + // const cthour = new Date() + // cthour.setTime(cthour.getTime() - 3599 * 1000) + // const hour = dateToString(cthour, 'y-m-d-h-m-s') + // const params = { params: [val[0], hour, now] } // const params = { params: [val[0], '2021-05-16 16:00:11', '2021-05-16 16:59:11'] } - fetchCarPostion(params).then(response => { - if (response.code === 200) { - if (response.data.length !== 0) { - var data = response.data.map(item => { return [item.coordinateX, item.coordinateY, 0] }) + // fetchCarPostion(params).then(response => { + // if (response.code === 200) { + // if (response.data.length !== 0) { + var data = this.data.feature[str].geo.map(item => { return [item.split(' ')[0], item.split(' ')[1], 0] }) + console.log(data, 'data') var flydata = { name: '贴地表表面漫游', - speed: 300, + speed: 200, positions: data, model: { url: '../static/model/zhatuchelvse.gltf', heading: 180, - minimumPixelSize: 50, + minimumPixelSize: 25, show: true }, label: { - text: val[1], + text: this.data.feature[str].name, font_size: 18, color: '#ffffff', pixelOffsetY: -50, @@ -495,11 +503,12 @@ var roamLine = new mars3d.graphic.RoamLine(flydata) this.layers.feature.addGraphic(roamLine) roamLine.start() - } - } - }) + // } + // } + // }) }, fetchData ({value}) { + // console.log(value, 'value') this.showCommunityInfo = false this.layers.feature.clear() this.layers.polygon.clear() @@ -517,9 +526,10 @@ this.bottom_choose = [] } if (value.index === '27') { - var that = this - this.getCar() - this.cartimer = setInterval(function () { that.getCar() }, 100000) + // var that = this + // console.log('获取车辆') + // this.getCar() + // this.cartimer = setInterval(function () { that.getCar() }, 100000) } else if (value === '电子标识器') { this.singleSearch(value, 'B-ZH-0101', '3KNOXR30E6', require('@/assets/images/icon-camera-blu.png'), [ {name: '标识器ID号', value: 'SJBH'}, {name: '标识器型号', value: 'SBXH'}, {name: '所属道路', value: 'SSSJFW'} ], false) @@ -849,6 +859,103 @@ this.showCommunityInfo = true break } + }, + drawCar() { + this.showCommunityInfo = false + this.layers.feature.clear() + this.layers.polygon.clear() + if (this.layers.heatLayer) { + this.map.removeLayer(this.layers.heatLayer, true) + } + clearInterval(this.cartimer) + fetchCarInfo().then(res => { + // console.log(res.data, '车辆信息') + this.data.feature = res.data + for (let i = 0; i < this.data.feature.length; i++) { + var graphic = new mars3d.graphic.ModelEntity({ + name: this.data.feature[i].name, + position: [Number(this.data.feature[i].X), Number(this.data.feature[i].Y)], + style: { + url: '../static/model/zhatuchelvse.gltf', + scale: 0.5, + minimumPixelSize: 25, + label: { + text: this.data.feature[i].location, + font_size: 18, + color: '#ffffff', + pixelOffsetY: -50, + distanceDisplayCondition: true, + distanceDisplayCondition_far: 500000, + distanceDisplayCondition_near: 1000 + } + } + }) + var items = [{name: '车牌号', value: 'name'}, {name: '车辆状态', value: 'statusname'}, + {name: '车辆类型', value: 'typename'},{name: '车辆位置', value: 'location'}, + ] + var str = ` +
+
渣土车分布
` + for (let j in items) { + var item = this.data.feature[i][items[j].value] + if (typeof item === 'undefined') item = '' + str += `
${item}
` + } + // var simcardnum = '\'' + this.data.feature[i].simcardnum + '!' + this.data.feature[i].vehiclenum + '\'' + // var vehiclenum = this.data.feature[i].vehiclenum + str += `` + str += `
` + graphic.bindPopup(str) + this.layers.feature.addGraphic(graphic) + if (i === 5) { + this.map.setCameraView({ lat: Number(25.808901), lng: Number(114.928765), alt: 3000, heading: 360, pitch: -31}) + } + } + // for (let i = 0; i < this.data.feature.length; i++) { + // var graphic = new mars3d.graphic.BillboardEntity({ + // name: '车辆', + // position: [Number(this.data.feature[i].X), Number(this.data.feature[i].Y)], + // style: { + // image: require('@/assets/images/icon-camera-blu.png'), + // scale: 1, + // horizontalOrigin: Cesium.HorizontalOrigin.CENTER, + // verticalOrigin: Cesium.VerticalOrigin.BOTTOM, + // clampToGround: true + // } + // }) + // // 绑定点击事件 + // graphic.on('click', (event) => { + // // 执行自定义点击逻辑 + // this.handleBillboardClick('车辆', graphic) + // }) + + // var str = ` + //
+ //
车辆信息
+ //
${this.data.feature[i].name}
+ //
${this.data.feature[i].statusname}
+ //
${this.data.feature[i].typename}
+ //
${this.data.feature[i].location}
+ // ` + // // for (let j in items) { + // // var item = this.data.feature[i][items[j].value] + // // if (typeof item === 'undefined') item = '' + // // str += `
${item}
` + // // } + // // if (showbtn) { + // // var SSKZQBH = '\'' + this.data.feature[i].SSKZQBH + '\'' + // // str += `` + // // } + // // str += `
` + // graphic.bindPopup(str) + // this.layers.feature.addGraphic(graphic) + // if (i === 0) { + // this.map.setCameraView({ lat: Number(this.data.feature[i].Y), lng: Number(this.data.feature[i].X), alt: 20000}) + // } + // } + }) } } }