|
|
|
@ -2,13 +2,27 @@
|
|
|
|
|
<div class="map-container">
|
|
|
|
|
<div class="input-search" ref="targetElement">
|
|
|
|
|
<div class="search-box">
|
|
|
|
|
<input type="text" placeholder="请输入路线或者临时任务名称" />
|
|
|
|
|
<div class="search-btn" @click="show = !show">搜索</div>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
v-model="searchQuery.carPlate"
|
|
|
|
|
placeholder="请输入正确的车牌号"
|
|
|
|
|
/>
|
|
|
|
|
<i
|
|
|
|
|
class="el-icon-error icon-close"
|
|
|
|
|
v-show="searchQuery.carPlate"
|
|
|
|
|
@click="inputClear()"
|
|
|
|
|
></i>
|
|
|
|
|
<div class="search-btn" @click="handleSearch()">搜索</div>
|
|
|
|
|
</div>
|
|
|
|
|
<el-collapse-transition>
|
|
|
|
|
<div v-show="show" class="search-list">
|
|
|
|
|
<div class="list-item" v-for="(item, index) in 5" :key="index">
|
|
|
|
|
002号线_01_维护_守押085_苏E
|
|
|
|
|
<div
|
|
|
|
|
class="list-item"
|
|
|
|
|
v-for="item in searchList"
|
|
|
|
|
:key="item.carId"
|
|
|
|
|
@click="handelLookCar(item)"
|
|
|
|
|
>
|
|
|
|
|
{{ item.carName }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-collapse-transition>
|
|
|
|
@ -33,20 +47,26 @@
|
|
|
|
|
{{ item }}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- <div class="video-list" v-show="showVideo">
|
|
|
|
|
<grids></grids>
|
|
|
|
|
</div> -->
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import MarsMap from "@/components/mars-map";
|
|
|
|
|
// import grids from "@/components/grids.vue";
|
|
|
|
|
import { getCarPoint } from "@/api/yunkun/yunkun.js";
|
|
|
|
|
|
|
|
|
|
import { getCarPoint, getCarByCarplate } from "@/api/yunkun/yunkun.js";
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
const basePathUrl = window.basePathUrl || "";
|
|
|
|
|
return {
|
|
|
|
|
searchList: [],
|
|
|
|
|
searchQuery: {
|
|
|
|
|
carPlate: undefined, //车牌
|
|
|
|
|
plateColor: undefined, //车辆颜色
|
|
|
|
|
},
|
|
|
|
|
carQuery: {
|
|
|
|
|
teamId: "", //该参数表示获取指定车队下所有层级子车队的车辆定位,该参数优先级别高于carIds参数,
|
|
|
|
|
carIds: "", //车辆id 多个用逗号分开,优先级低于teamId
|
|
|
|
|
},
|
|
|
|
|
list: [],
|
|
|
|
|
multipleList: ["营运线路", "维护线路", "临时任务"],
|
|
|
|
|
selectedItems: [],
|
|
|
|
@ -116,39 +136,77 @@ export default {
|
|
|
|
|
document.addEventListener("click", this.handleClickOutside);
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
/**输入框清除 */
|
|
|
|
|
|
|
|
|
|
inputClear() {
|
|
|
|
|
this.map.flyHome();
|
|
|
|
|
if (this.timer) clearInterval(this.timer);
|
|
|
|
|
this.searchList = [];
|
|
|
|
|
this.searchQuery.carPlate = undefined;
|
|
|
|
|
this.carQuery.carIds = undefined;
|
|
|
|
|
this.show = false;
|
|
|
|
|
this.getCarPoint();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**根据车牌号查询车辆实时定位 */
|
|
|
|
|
async handleSearch() {
|
|
|
|
|
if (!this.searchQuery.carPlate) return;
|
|
|
|
|
// 清除轮询定时器
|
|
|
|
|
if (this.timer) clearInterval(this.timer);
|
|
|
|
|
const result = await getCarByCarplate(this.searchQuery);
|
|
|
|
|
this.searchList = result.list;
|
|
|
|
|
this.show = true;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handelLookCar(item) {
|
|
|
|
|
this.list = [item];
|
|
|
|
|
this.carQuery.carIds = item.carId;
|
|
|
|
|
this.map.flyToPoint(
|
|
|
|
|
new mars3d.LngLatPoint(parseFloat(item.lng), parseFloat(item.lat))
|
|
|
|
|
);
|
|
|
|
|
this.createCar("active");
|
|
|
|
|
this.show = false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取车辆实时定位(可查全部)
|
|
|
|
|
*/
|
|
|
|
|
async getCarPoint() {
|
|
|
|
|
this.list = await this.carPoint();
|
|
|
|
|
this.createCar();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async carPoint() {
|
|
|
|
|
let res = await getCarPoint({
|
|
|
|
|
// carIds: "23,78",
|
|
|
|
|
});
|
|
|
|
|
let res = await getCarPoint(this.carQuery);
|
|
|
|
|
res.list = res.list.filter(
|
|
|
|
|
(item) =>
|
|
|
|
|
item.carPlate.includes("苏E") ||
|
|
|
|
|
(item.carPlate.includes("苏U") && item.stateCn.includes("在线-行驶"))
|
|
|
|
|
);
|
|
|
|
|
return res.list.slice(0, 100);
|
|
|
|
|
return res.list.slice(0, 50);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建车辆图标
|
|
|
|
|
*/
|
|
|
|
|
createCar() {
|
|
|
|
|
createCar(type) {
|
|
|
|
|
let _this = this;
|
|
|
|
|
this.graphicLayer.clear();
|
|
|
|
|
this.graphicLayer.enabledEvent = false; // 关闭事件,大数据addGraphic时影响加载时间
|
|
|
|
|
// 设置动态位置
|
|
|
|
|
for (let i = 0; i < this.list.length; i++) {
|
|
|
|
|
let item = this.list[i];
|
|
|
|
|
const graphic = new mars3d.graphic.ModelPrimitive({
|
|
|
|
|
const item = this.list[i];
|
|
|
|
|
let graphic = new mars3d.graphic.ModelPrimitive({
|
|
|
|
|
id: item.carId,
|
|
|
|
|
style: {
|
|
|
|
|
// heading: parseInt(item.drct),
|
|
|
|
|
url: this.carUrl,
|
|
|
|
|
scale: 3,
|
|
|
|
|
minimumPixelSize: 20,
|
|
|
|
|
silhouette: true,
|
|
|
|
|
silhouetteColor: "#0084ff",
|
|
|
|
|
silhouetteSize: 2,
|
|
|
|
|
pitch: 0,
|
|
|
|
|
roll: 0,
|
|
|
|
|
label: {
|
|
|
|
|
text: item.carName,
|
|
|
|
|
font_size: 14,
|
|
|
|
@ -156,31 +214,39 @@ export default {
|
|
|
|
|
outline: true,
|
|
|
|
|
outlineColor: "#000000",
|
|
|
|
|
pixelOffsetY: -30,
|
|
|
|
|
visibleDepth: false,
|
|
|
|
|
distanceDisplayCondition: true,
|
|
|
|
|
distanceDisplayCondition_far: 50000,
|
|
|
|
|
distanceDisplayCondition_near: 0,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// frameRateHeight: 30, // 控制贴模型的效率,多少帧计算一次
|
|
|
|
|
// autoMiddleDynamicPosition: true, //如果中间缺少数据时是否自动添加中间点
|
|
|
|
|
frameRateHeight: 30, // 控制贴模型的效率,多少帧计算一次
|
|
|
|
|
});
|
|
|
|
|
this.graphicLayer.addGraphic(graphic);
|
|
|
|
|
this.graphicLayer.enabledEvent = true; // 恢复事件
|
|
|
|
|
// graphic.bindHighlight({
|
|
|
|
|
// type: mars3d.EventType.click,
|
|
|
|
|
// silhouette: true,
|
|
|
|
|
// silhouetteColor: "#FAAC51",
|
|
|
|
|
// silhouetteSize: 2,
|
|
|
|
|
// label: {
|
|
|
|
|
// outlineColor: "#FAAC51",
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
// graphic.on(mars3d.EventType.click, function (e) {
|
|
|
|
|
// _this.$router.push({ path: "/carInfo" });
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
if (type) {
|
|
|
|
|
graphic.openHighlight({
|
|
|
|
|
scale: 5,
|
|
|
|
|
silhouette: true,
|
|
|
|
|
silhouetteColor: "#FAAC51",
|
|
|
|
|
silhouetteSize: 2,
|
|
|
|
|
label: {
|
|
|
|
|
outlineColor: "#FAAC51",
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
graphic.on(mars3d.EventType.click, function (e) {
|
|
|
|
|
_this.$router.push({
|
|
|
|
|
path: "/carInfo",
|
|
|
|
|
query: { carId: e.target.id },
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.changePosition(0);
|
|
|
|
|
// 定时更新动态位置(setInterval为演示)
|
|
|
|
|
const interval = 10;
|
|
|
|
|
const interval = 15;
|
|
|
|
|
this.changePosition(interval);
|
|
|
|
|
this.time = setInterval(() => {
|
|
|
|
|
this.changePosition(interval);
|
|
|
|
@ -191,36 +257,17 @@ export default {
|
|
|
|
|
async changePosition(interval) {
|
|
|
|
|
let list = await this.carPoint();
|
|
|
|
|
this.graphicLayer.eachGraphic((graphic) => {
|
|
|
|
|
for (let i = 0; i < list.length; i++) {
|
|
|
|
|
let item = list[i];
|
|
|
|
|
if (graphic.id == item.carId) {
|
|
|
|
|
// graphic.setOptions({
|
|
|
|
|
// style: {
|
|
|
|
|
// heading: parseInt(item.drct),
|
|
|
|
|
// },
|
|
|
|
|
// });
|
|
|
|
|
let position = Cesium.Cartesian3.fromDegrees(
|
|
|
|
|
parseFloat(item.lng),
|
|
|
|
|
parseFloat(item.lat),
|
|
|
|
|
30
|
|
|
|
|
);
|
|
|
|
|
graphic.addDynamicPosition(position, interval); // 按time秒运动至指定位置
|
|
|
|
|
}
|
|
|
|
|
let carItam = list.filter((car) => car.carId == graphic.id);
|
|
|
|
|
if (carItam.length > 0) {
|
|
|
|
|
let position = Cesium.Cartesian3.fromDegrees(
|
|
|
|
|
parseFloat(carItam[0].lng),
|
|
|
|
|
parseFloat(carItam[0].lat),
|
|
|
|
|
30
|
|
|
|
|
);
|
|
|
|
|
graphic.addDynamicPosition(position, interval); // 按time秒运动至指定位置
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 取区域内的随机点
|
|
|
|
|
randomPoint() {
|
|
|
|
|
const jd = this.random(117.207666 * 1000, 117.287241 * 1000) / 1000;
|
|
|
|
|
const wd = this.random(31.817099 * 1000, 31.876848 * 1000) / 1000;
|
|
|
|
|
return Cesium.Cartesian3.fromDegrees(jd, wd, 30);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
random(min, max) {
|
|
|
|
|
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleClickOutside(event) {
|
|
|
|
|
// 判断点击的元素是否在目标元素外部
|
|
|
|
|
if (this.show && !this.$refs.targetElement.contains(event.target)) {
|
|
|
|
@ -247,7 +294,7 @@ export default {
|
|
|
|
|
this.graphicLayer = new mars3d.layer.GraphicLayer();
|
|
|
|
|
map.addLayer(this.graphicLayer);
|
|
|
|
|
// this.initTilesetLayer();
|
|
|
|
|
// this.getCarPoint();
|
|
|
|
|
this.getCarPoint();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -272,9 +319,7 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
this.map.addLayer(tiles3dLayer);
|
|
|
|
|
|
|
|
|
|
if (process.env.NODE_ENV === "production") this.chkShadows(true);
|
|
|
|
|
|
|
|
|
|
tiles3dLayer.on(mars3d.EventType.load, function (event) {
|
|
|
|
|
_this.getCarLocation();
|
|
|
|
|
});
|
|
|
|
@ -302,9 +347,17 @@ export default {
|
|
|
|
|
z-index: 100;
|
|
|
|
|
|
|
|
|
|
.search-box {
|
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
height: 32px;
|
|
|
|
|
.icon-close {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 260px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
color: #0084ff;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.search-btn {
|
|
|
|
|
cursor: pointer;
|
|
|
|
@ -340,6 +393,7 @@ export default {
|
|
|
|
|
border: 1px solid #0084ff;
|
|
|
|
|
border-top: 0;
|
|
|
|
|
& > div {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
}
|
|
|
|
|