You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

335 lines
8.9 KiB

<template>
<div class="map-container">
<div class="container-top">
<div class="next-stand">
<img src="../assets/images/next.png" alt="" />
8 months ago
<span>0</span>
</div>
<div class="real-time">
<img src="../assets/images/realTime.png" alt="" />
8 months ago
<span>{{ mileData.mile ? ileData.mile : 0 }}</span>
</div>
</div>
8 months ago
<div class="albuginea backBtn" @click="initTilesetLayer()">
{{ show3D ? "关闭" : "开启" }}三维
</div>
<div class="albuginea" @click="$router.back()">
<i class="el-icon-back"></i> 返回
</div>
<mars-map @mapLoad="mapLoad" :options="options"></mars-map>
<div class="video-list">
<grids></grids>
</div>
</div>
</template>
<script>
import MarsMap from "@/components/mars-map";
import grids from "@/components/grids.vue";
import { getCarIdInfo } from "@/api/yunkun/index.js";
8 months ago
import { historyLine, carMidle } from "@/api/yunkun/yunkun.js";
export default {
data() {
const basePathUrl = window.basePathUrl || "";
return {
8 months ago
mileData: {
mile: "", //已经行驶多少里程
},
queryParams: {
startTime: undefined,
endTime: undefined,
},
map: null,
8 months ago
mapLayer: {},
show3D: false,
options: {
scene: {
center: {
8 months ago
lat: 31.184348,
lng: 120.625126,
alt: 6764.6,
heading: 357.9,
pitch: -31.5,
},
},
control: {
8 months ago
// contextmenu: { preventDefault: false, hasDefault: false },
},
},
8 months ago
Line: [],
8 months ago
carUrl: basePathUrl + "lib/qiche.gltf",
};
},
components: { MarsMap, grids },
beforeDestroy() {},
8 months ago
created() {},
methods: {
8 months ago
/**地图渲染完毕 */
mapLoad(map) {
this.map = map;
8 months ago
map.fixedLight = true; // 固定光照避免gltf模型随时间存在亮度不一致。
// 创建矢量图层
this.mapLayer.Line = new mars3d.layer.GraphicLayer();
this.map.addLayer(this.mapLayer.Line);
8 months ago
this.mapLayer.car = new mars3d.layer.GraphicLayer();
this.map.addLayer(this.mapLayer.car);
8 months ago
this.createLine();
this.createCar();
8 months ago
},
8 months ago
/**
* 加载姑苏区三维图层
*/
initTilesetLayer() {
if (this.map) {
if (!this.mapLayer.tiles3dLayer) {
this.mapLayer.tiles3dLayer = new mars3d.layer.TilesetLayer({
name: "姑苏区建筑物",
url: "https://www.jichuanglanhai.com:88/3dtiles/yunkun/tileset.json",
maximumScreenSpaceError: 16,
maximumMemoryUsage: 1024 / 2,
dynamicScreenSpaceError: false,
skipLevelOfDetail: true,
preferLeaves: true,
flyTo: false,
style: {
color: {
conditions: [["true", `color("rgba(42, 160, 224, 1)")`]],
},
},
});
this.map.addLayer(this.mapLayer.tiles3dLayer);
this.show3D = true;
} else {
this.mapLayer.tiles3dLayer.show = !this.mapLayer.tiles3dLayer.show;
this.show3D = !this.show3D;
}
} else {
}
},
// 绘制历史轨迹线 -- 起点坐标
createLine() {
this.Line = [
[120.60011, 31.26247],
[120.599811, 31.267667],
[120.599341, 31.27582],
[120.59705, 31.278812],
[120.599466, 31.279271],
[120.61856, 31.28155],
[120.642973, 31.284112],
];
const marker = new mars3d.graphic.BillboardEntity({
position: this.Line[0],
style: {
8 months ago
image: require("../assets/images/origin.png"),
scale: 1,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
clampToGround: true,
8 months ago
pixelOffsetY: 5,
},
});
8 months ago
this.mapLayer.Line.addGraphic(marker);
8 months ago
const line = new mars3d.graphic.PolylineEntity({
positions: this.Line,
style: {
width: 10,
color: "#00F7AC",
outline: true,
outlineColor: "#008DF8",
outlineWidth: 5,
clampToGround: true,
},
});
8 months ago
this.mapLayer.Line.addGraphic(line);
8 months ago
8 months ago
// 创建起始点坐标
8 months ago
},
8 months ago
//创建实时车辆漫游
async createCar() {
const lastPoint = this.Line[this.Line.length - 1];
const car = new mars3d.graphic.FixedRoute({
name: "漫游对象",
speed: 45,
positions: [
lastPoint,
[120.6554, 31.285252, 13.6],
[120.654003, 31.298916, 10.8],
[120.649845, 31.299078, 14.2],
[120.647362, 31.308061, 17.4],
[120.645631, 31.314448, 16.1],
[120.638285, 31.312808, 10],
],
// camera: {
// type: "gs",
// heading: 0,
// radius: 3000,
// },
9 months ago
model: {
show: true,
8 months ago
url: this.carUrl,
scale: 0.5,
minimumPixelSize: 30,
9 months ago
silhouette: true,
8 months ago
silhouetteColor: "#FFB200",
},
circle: {
8 months ago
radius: 200,
materialType: mars3d.MaterialType.CircleWave,
materialOptions: {
8 months ago
color: "#FFB200",
count: 2,
8 months ago
speed: 6,
},
},
8 months ago
polyline: {
width: 10,
color: "#00F7AC",
outline: true,
outlineColor: "#008DF8",
outlineWidth: 5,
clampToGround: true,
},
});
8 months ago
this.mapLayer.car.addGraphic(car);
let res = await getCarIdInfo("1328CC51-C858-4FFA-8714-4F354BB49CF8");
this.bindPopup(car, res.data);
car.openPopup();
car.start();
},
8 months ago
// 车辆弹窗
bindPopup(fixedRoute, data) {
const userList = data.userList.map((item) => {
return `<div class="popup-item">
<div class="popup-lable">${item.name}</div>
<div class="popup-value">${item.ename}</div>
</div>`;
});
const zbList = data.zbList.map((item) => {
return `<div class="popup-item">
<div class="popup-lable">${item.thingType}</div>
<div class="popup-value">${item.type}</div>
</div>`;
});
let html = `<div class="diy-popup">
8 months ago
<div class="pointer"></div>
<div class="popup-title">001号线_01_早送_守押<br/>
001_苏E12345
</div>
<div class="popup-item">
<div class="popup-lable">线路类型</div>
<div class="popup-value">${data.lineType}</div>
</div>
<div class="sub-title">装备信息</div>
<div class="popup-grid">
${zbList.join("")}
</div>
<div class="sub-title">人员信息</div>
<div class="popup-grid">
${userList.join("")}
</div>
<div class="sub-title">标的物信息</div>
<div class="popup-grid">
<div class="popup-item">
<div class="popup-lable">标的物总数</div>
<div class="popup-value">${data.bdwInfo.count}</div>
</div>
</div>
</div>`;
fixedRoute.bindPopup(html, {
className: "carPopup",
offsetX: 280,
8 months ago
offsetY: 100,
// closeButton: false,
});
},
},
};
</script>
<style lang="scss" scoped>
8 months ago
.albuginea {
cursor: pointer;
position: absolute;
top: 103px;
left: 554px;
z-index: 100;
width: 80px;
height: 32px;
text-align: center;
line-height: 32px;
background: #032b57;
border-radius: 2px;
border: 1px solid #0084ff;
font-weight: 400;
font-size: 14px;
color: #ffffff;
}
.backBtn {
top: 145px;
}
.albuginea:hover {
background: #0084ff;
}
.container-top {
position: fixed;
8 months ago
top: 100px;
left: 50%;
transform: translateX(-50%);
z-index: 100;
display: flex;
align-items: center;
justify-content: center;
.next-stand {
margin-right: 40px;
}
& > div {
width: 200px;
img {
height: 38px;
width: 100%;
display: block;
margin-bottom: 10px;
}
span {
display: block;
font-size: 40px;
color: #ffffff;
line-height: 51px;
letter-spacing: 1px;
text-align: center;
font-style: normal;
background: linear-gradient(270deg, #00e5ff 0%, #d8d8d8 100%);
/* 将背景限制在文字区域内 */
-webkit-background-clip: text;
background-clip: text;
/* 设置文字颜色,会被背景图像遮住 */
color: transparent;
font-family: "DIN-Regular-2";
}
}
}
.video-list {
position: absolute;
bottom: 25px;
left: 50%;
transform: translateX(-50%);
z-index: 100;
padding: 10px;
display: flex;
align-items: center;
border: 1px solid #415367;
border-radius: 10px;
background: rgba(28, 31, 34, 0.6);
}
</style>