Commit ac089eb9 authored by caicaicai's avatar caicaicai

修改

parent b19ed065
...@@ -30,64 +30,19 @@ export default { ...@@ -30,64 +30,19 @@ export default {
name: 'mars3dViewer', name: 'mars3dViewer',
created(){ created(){
this.getCoordinate(); this.getCarInforFn();
}, },
data(){ data(){
return{ return{
historyTrajectoryData:[], historyTrajectoryData:[],
persons:[
["122.128833", "37.526448", "500"],
["122.128638", "37.522818", "500"],
["122.128738", "37.522818", "500"],
["122.128638", "37.528518", "500"],
["122.128538", "37.528818", "500"],
["122.128538", "37.525818", "500"],
["122.121538", "37.523318", "500"],
["122.127833", "37.525448", "500"],
["122.128833", "37.526448", "500"],
["122.128638", "37.522818", "500"],
["122.128738", "37.522818", "500"],
["122.128638", "37.528518", "500"],
["122.128538", "37.528818", "500"],
["122.128538", "37.525818", "500"],
["122.121538", "37.523318", "500"],
["122.127833", "37.525448", "500"],
["122.128833", "37.526448", "500"],
["122.128638", "37.522818", "500"],
["122.128738", "37.522818", "500"],
["122.128638", "37.528518", "500"],
["122.128538", "37.528818", "500"],
["122.128538", "37.525818", "500"],
["122.121538", "37.523318", "500"],
["122.127833", "37.525448", "500"],
["122.128833", "37.526448", "500"],
["122.128638", "37.522818", "500"],
["122.128738", "37.522818", "500"],
["122.128638", "37.528518", "500"],
["122.128538", "37.528818", "500"],
["122.128538", "37.525818", "500"],
["122.121538", "37.523318", "500"],
["122.127833", "37.525448", "500"],
["122.128833", "37.526448", "500"],
["122.128638", "37.522818", "500"],
["122.128738", "37.522818", "500"],
["122.128638", "37.528518", "500"],
["122.128538", "37.528818", "500"],
["122.128538", "37.525818", "500"],
["122.121538", "37.523318", "500"],
["122.127833", "37.525448", "500"],
],
deviceId:'DESKTOP-L56LKGM',
zuobianData:[], zuobianData:[],
toJavaCoordinates:[], toJavaCoordinates:[],
weilanName:[], weilanName:[],
areaColorData:[], areaColorData:[],
allCarInforData:[],
defaultjd:117.12111,
defaultwd:36.679,
} }
}, },
...@@ -129,6 +84,16 @@ export default { ...@@ -129,6 +84,16 @@ export default {
}, },
methods: { methods: {
//获取实时位置
getCarInforFn(){
HttpReq.truckDispatching.carInformationQuery({size:9999}).then((res) => {
if(res.code == 200){
this.allCarInforData = res.data.content;
this.getCoordinate();
}
})
},
//后台获取数据——获取电子围栏 //后台获取数据——获取电子围栏
getCoordinate() { getCoordinate() {
let that = this; let that = this;
...@@ -150,22 +115,6 @@ export default { ...@@ -150,22 +115,6 @@ export default {
} }
that.zuobianData = data1 that.zuobianData = data1
//console.log("zuobianData",that.zuobianData);
//console.log("weilanName",that.weilanName);
this.getlishiguijiFn();
}
})
},
//后台获取数据——获取实时位置
getlishiguijiFn() {
let that = this;
HttpReq.truckDispatching.getCarTrajectoryQuery().then((res) => {
//console.log(res);
if(res.code == 200){
that.historyTrajectoryData = res.data;
this.$nextTick(()=>{ this.$nextTick(()=>{
if (this.appendToBody) { if (this.appendToBody) {
...@@ -182,6 +131,7 @@ export default { ...@@ -182,6 +131,7 @@ export default {
} }
}) })
}, },
//创建地图 //创建地图
...@@ -209,16 +159,17 @@ export default { ...@@ -209,16 +159,17 @@ export default {
that.addGraphic_01(graphicLayer,item,that.weilanName[index],that.areaColorData[index]); that.addGraphic_01(graphicLayer,item,that.weilanName[index],that.areaColorData[index]);
}) })
//实时位置 //实时位置1
// that.historyTrajectoryData.forEach((item,index)=>{ // that.allCarInforData.forEach((item,index)=>{
// var graphicLayer4 = new mars3d.layer.GraphicLayer(); // var graphicLayer4 = new mars3d.layer.GraphicLayer();
// map.addLayer(graphicLayer4) // map.addLayer(graphicLayer4);
// that.addDemoGraphics(graphicLayer4,item); // that.addDemoGraphics(graphicLayer4,item.number,item.equipmentName,item.carclass);
// }) // })
// 抛出事件 // 抛出事件
this.$emit('onload', map) this.$emit('onload', map)
}, },
//围栏回显 //围栏回显
addGraphic_01(graphicLayer,positions,weilanName,color){ addGraphic_01(graphicLayer,positions,weilanName,color){
let graphic = new mars3d.graphic.PolygonEntity({ let graphic = new mars3d.graphic.PolygonEntity({
...@@ -241,24 +192,16 @@ export default { ...@@ -241,24 +192,16 @@ export default {
}); });
graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer) graphicLayer.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
}, },
getSampledPositionProperty(points){
let property = new Cesium.SampledPositionProperty(); //实时位置1
let start = this.map.clock.currentTime; addDemoGraphics(graphicLayer4,number,equipmentName,carclass) {
let positions = mars3d.LatLngArray.toCartesians(points);
for (let i = 0; i < positions.length; i++) {
let time = Cesium.JulianDate.addSeconds(start, i * 20, new Cesium.JulianDate());
let position = positions[i];
property.addSample(time, position);
}
return property;
},
//实时位置
addDemoGraphics(graphicLayer4,item) {
let that = this; let that = this;
//模型配置
const graphic = new mars3d.graphic.ModelPrimitive({ const graphic = new mars3d.graphic.ModelPrimitive({
style: { style: {
url: "//data.mars3d.cn/gltf/mars/car/tufangche.glb", url: carclass == '电铲' ? '//data.mars3d.cn/gltf/mars/qzcar/GKZY_anim.gltf' : '//data.mars3d.cn/gltf/imap/1d4f63111fc9499dac5cee2286ad7bb3/gltf/gltf2.gltf',
scale: 0.1, scale: 2,
minimumPixelSize: 50, minimumPixelSize: 50,
// 高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用 // 高亮时的样式(默认为鼠标移入,也可以指定type:'click'单击高亮),构造后也可以openHighlight、closeHighlight方法来手动调用
highlight: { highlight: {
...@@ -269,9 +212,9 @@ export default { ...@@ -269,9 +212,9 @@ export default {
}, },
label: { label: {
// 不需要文字时,去掉label配置即可 // 不需要文字时,去掉label配置即可
text: item.name, text: number,
font_size: 16, font_size: 22,
color: "#ffffff", color: "#ff0000",
outline: true, outline: true,
outlineColor: "#000000", outlineColor: "#000000",
pixelOffsetY: -20, pixelOffsetY: -20,
...@@ -279,34 +222,44 @@ export default { ...@@ -279,34 +222,44 @@ export default {
distanceDisplayCondition_far: 50000, distanceDisplayCondition_far: 50000,
distanceDisplayCondition_near: 0 distanceDisplayCondition_near: 0
} }
}, }
}) })
//载入图层
graphicLayer4.addGraphic(graphic) graphicLayer4.addGraphic(graphic)
//初始位置
// 设置动态位置
graphicLayer4.eachGraphic((graphic) => { graphicLayer4.eachGraphic((graphic) => {
graphic.addDynamicPosition(Cesium.Cartesian3.fromDegrees(item.lat, item.lon, 500)) // 首次出现的位置 graphic.addDynamicPosition(Cesium.Cartesian3.fromDegrees(117.12111, 36.679, 1000))
}) })
//五秒后位置
graphicLayer4.eachGraphic((graphic) => { graphicLayer4.eachGraphic((graphic) => {
graphic.addDynamicPosition(that.randomPoint(item.name), 6) // 按6秒运动至指定位置 graphic.addDynamicPosition(Cesium.Cartesian3.fromDegrees(117.12111, 36.679, 1000), 5)
})
//定时更新动态位置
setInterval(() => {
HttpReq.truckDispatching.getOneHistroyCarTrajectoryQuery({name:equipmentName}).then((res) => {
if(res.data){
graphicLayer4.eachGraphic((graphic) => {
graphic.addDynamicPosition(Cesium.Cartesian3.fromDegrees(res.data.lon, res.data.lat, 1000), 5)
})
}else{
graphicLayer4.eachGraphic((graphic) => {
graphic.addDynamicPosition(Cesium.Cartesian3.fromDegrees(117.12111, 36.679, 1000), 5)
}) })
// 定时更新动态位置(setInterval为演示)
// setInterval(() => {
// graphicLayer4.eachGraphic((graphic) => {
// graphic.addDynamicPosition(that.randomPoint(item.name), 6)
// })
// }, 6000)
},
// 取区域内的随机点
randomPoint(name) {
HttpReq.truckDispatching.getCarTrajectoryQuery({name:name}).then((res) => {
if(res.code == 200){
return Cesium.Cartesian3.fromDegrees(res.data[0].lat, res.data[0].lon, 500)
} }
}) })
}, 4000)
}, },
// 在图层绑定Popup弹窗
bindLayerPopup(graphicLayer,number) {
let that = this;
graphicLayer.bindPopup(function (event) {
that.$parent.smallWinFn(number);
})
}
} }
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment