样式修复

main
许宏杰 9 months ago
parent dda0614753
commit dcf9691bfa

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 959 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -14,19 +14,20 @@
text-align: center;
}
.mars-four-color {
width: 84px;
width: 100px;
position: relative;
top: -68px;
left: -40px;
top: -60px;
left: -50px;
cursor: pointer;
}
.four-color_name {
width: 100%;
height: 80px;
line-height: 30px;
height: 100px;
line-height: 37px;
background: url("../images/areaName.png");
background-size: 100% 100%;
font-size: 14px;
font-size: 16px;
font-weight: bold;
color: #fff250;
text-align: center;
text-shadow: 0px 0px 2px rgba(0, 0, 0, 0.5);
@ -34,7 +35,7 @@
.mars3d-animation {
position: relative;
animation: moveUpDown 1s linear infinite alternate;
// animation: moveUpDown 1s linear infinite alternate;
}
@keyframes moveUpDown {
@ -49,33 +50,35 @@
.screen-list {
position: absolute;
top: 0;
right: -195px;
right: -240px;
// transform: translateY(50%);
min-width: 60px;
opacity: 0;
& > div {
display: none;
}
.lable-value {
height: 35px;
width: 190px;
height: 41px;
width: 234px;
background: url("../images/screen-list.png");
background-size: 100% 100%;
margin-bottom: 3px;
display: flex;
align-items: center;
padding: 0 4px;
padding: 0 6px;
.lable-data {
width: 50%;
font-size: 14px;
font-size: 16px;
color: #612500;
font-weight: bold;
}
.value-data {
flex: 1;
text-align: center;
font-size: 18px;
font-size: 20px;
color: #f7c75d;
font-family: "DIN-Regular-2";
span {
font-size: 14px;
font-size: 16px;
color: #ffffff;
}
}
@ -110,7 +113,7 @@
.video-dialog {
background-color: transparent;
width: 833px;
width: 750px;
height: 482px;
.el-dialog__header {
padding: 0;
@ -118,7 +121,7 @@
.el-dialog__body {
height: 100%;
padding: 15px 10px;
background: url("../images/dialog.jpg");
background: url("../images/dialog.png");
background-size: 100% 100%;
}
.el-dialog__headerbtn {
@ -149,12 +152,23 @@
}
.diy-popup {
position: relative;
height: 430px;
width: 260px;
background: url("../images/diy-popup.png");
background-size: 100% 100%;
padding: 20px 25px;
overflow-y: auto;
// overflow-y: auto;
.pointer {
position: absolute;
left: -145px;
top: 50%;
transform: translateY(-50%);
width: 145px;
height: 207px;
background: url("../images/pointer.png");
background-size: cover;
}
.popup-title {
font-size: 18px;
color: #ffffff;
@ -194,3 +208,38 @@
}
}
}
.mars3d-popup-content {
overflow-y: visible;
}
//
.car-page-popup {
.mars3d-popup-tip-container {
opacity: 0;
}
.mars3d-popup-background {
background: transparent;
box-shadow: 0 0px 0px transparent;
padding: 0;
text-align: left;
border-radius: 0;
}
.carPlate {
position: relative;
background: #00162d;
border-radius: 4px;
border: 1px solid #008cff;
padding: 2px 10px;
font-size: 14px;
padding-left: 30px;
.carType {
position: absolute;
left: 0;
top: 0;
display: inline-block;
height: 25px;
width: 25px;
}
}
}

@ -93,14 +93,14 @@ export default {
background-color: #fff;
font-size: 14px;
opacity: 0.3;
opacity: 0.5;
border: none;
outline: none;
cursor: pointer;
padding: 9px 4px;
}
.scroll-btn:hover {
opacity: 0.5;
opacity: 0.8;
}
.left {

@ -0,0 +1,65 @@
const obj = {
borderWidth: 2,
borderColor: "#006FCB",
backgroundColor: "#00162D",
fontSize: 14,
fontColor: "#FFFFFF",
paddingVertical: 6,
paddingHorizontal: 10,
text: "001号线_01_早送_守押001_苏E", // 这里可以更改为需要绘制的文字
};
export function adjustCanvasSize(id) {
const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
// 设置文字样式以计算文本宽度
ctx.font = `${obj.fontSize}px sans-serif`;
// 计算文本宽度
const textWidth = ctx.measureText(obj.text).width;
// 计算画布宽度和高度(加上内边距和边框)
const canvasWidth = textWidth + obj.paddingHorizontal * 2;
const canvasHeight = obj.fontSize + obj.paddingVertical * 2;
// 设置画布宽度和高度
canvas.width = canvasWidth;
canvas.height = canvasHeight;
// 重新绘制矩形和文字
return drawRectangle(canvas, id, canvasWidth, canvasHeight, textWidth);
}
function drawRectangle(canvas, id, canvasWidth, canvasHeight, textWidth) {
let marker = document.getElementById("carMarker");
canvas.id = id;
const ctx = canvas.getContext("2d");
// 清空画布
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
// 绘制背景矩形
ctx.fillStyle = obj.backgroundColor;
ctx.fillRect(0, 0, canvasWidth, canvasHeight);
// 绘制边框
ctx.lineWidth = obj.borderWidth;
ctx.strokeStyle = obj.borderColor;
ctx.strokeRect(0.5, 0.5, canvasWidth - 1, canvasHeight - 1);
// 设置文字样式
ctx.font = `${obj.fontSize}px sans-serif`;
ctx.fillStyle = obj.fontColor;
// 计算文字的水平和垂直居中位置
const textX = (canvasWidth - textWidth) / 2;
const textY = (canvasHeight + obj.fontSize) / 2 - obj.paddingVertical / 2;
// 绘制文字
ctx.fillText(obj.text, textX, textY);
marker.appendChild(canvas);
return canvas;
}
export function changeBorderColor(id) {
let canvas = document.getElementById(id);
console.log(id, canvas);
canvas.style.border = `1px solid #C08700`;
}

@ -0,0 +1,79 @@
<template>
<canvas ref="myCanvas"></canvas>
</template>
<script>
export default {
data() {
return {
borderWidth: 2,
borderColor: "#006FCB",
backgroundColor: "#00162D",
fontSize: 14,
fontColor: "#FFFFFF",
paddingVertical: 3,
paddingHorizontal: 6,
text: "001号线_01_早送_守押001_苏E", //
};
},
mounted() {
this.adjustCanvasSize();
},
methods: {
adjustCanvasSize() {
const canvas = this.$refs.myCanvas;
const ctx = canvas.getContext("2d");
//
ctx.font = `${this.fontSize}px sans-serif`;
//
const textWidth = ctx.measureText(this.text).width;
//
const canvasWidth = textWidth + this.paddingHorizontal * 2;
const canvasHeight = this.fontSize + this.paddingVertical * 2;
//
canvas.width = canvasWidth;
canvas.height = canvasHeight;
//
this.drawRectangle(canvasWidth, canvasHeight, textWidth);
},
drawRectangle(canvasWidth, canvasHeight, textWidth) {
const canvas = this.$refs.myCanvas;
const ctx = canvas.getContext("2d");
//
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
//
ctx.fillStyle = this.backgroundColor;
ctx.fillRect(0, 0, canvasWidth, canvasHeight);
//
ctx.lineWidth = this.borderWidth;
ctx.strokeStyle = this.borderColor;
ctx.strokeRect(0.5, 0.5, canvasWidth - 1, canvasHeight - 1);
//
ctx.font = `${this.fontSize}px sans-serif`;
ctx.fillStyle = this.fontColor;
//
const textX = (canvasWidth - textWidth) / 2;
const textY = (canvasHeight + this.fontSize) / 2 - this.paddingVertical;
//
ctx.fillText(this.text, textX, textY);
},
},
};
</script>
<style scoped>
canvas {
display: block;
margin: 20px;
}
</style>

@ -0,0 +1,452 @@
<template>
<div class="map-container">
<div class="input-search" ref="targetElement">
<div class="search-box">
<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 in searchList"
:key="item.carId"
@click="handelLookCar(item)"
>
{{ item.carName }}
</div>
</div>
</el-collapse-transition>
</div>
<mars-map @mapLoad="mapLoad" :options="options"></mars-map>
<div class="multiple">
<div
@click="toggleSelection(item)"
:class="{ checkbox: true, checked: isSelected(item) }"
v-for="(item, index) in multipleList"
:key="index"
>
<img
:src="require(`../assets/images/${item}.png`)"
alt=""
class="btn-icon"
/>
{{ item }}
</div>
</div>
</div>
</template>
<script>
import MarsMap from "@/components/mars-map";
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: [],
graphicLayer: null,
baseUrl: basePathUrl + "lib/geoJson/tileset.json",
carUrl: basePathUrl + "lib/qiche.gltf",
map: null,
options: {
scene: {
// center: {
// lat: 31.754913,
// lng: 117.248572,
// alt: 6220,
// heading: 357,
// pitch: -31,
// },
center: {
lat: 31.212805,
lng: 120.607156,
alt: 5096.4,
heading: 357.9,
pitch: -31.5,
},
fog: false,
fxaa: false,
removeDblClick: true,
requestRenderMode: false,
scene3DOnly: false,
sceneMode: 3,
shadows: false,
showMoon: false,
showSkyAtmosphere: false,
showSkyBox: false,
showSun: false,
},
control: {
contextmenu: { preventDefault: false, hasDefault: false },
},
basemaps: [
// {
// name: "mapbox",
// icon: "img/basemaps/mapboxSatellite.png",
// type: "mapbox",
// username: "sharealex",
// styleId: "cly5i21fn00e901prgq643t4r",
// token:
// "pk.eyJ1Ijoic2hhcmVhbGV4IiwiYSI6ImNsaXNhZmRjbTFhbnczZmxib3h1OW05YXYifQ.PhlKv60ar3K359d8x2yBPw",
// tilesize: 256,
// scaleFactor: false,
// show: false,
// },
],
},
show: false,
showVideo: true,
};
},
components: { MarsMap },
beforeDestroy() {
clearInterval(this.timer);
//
document.removeEventListener("click", this.handleClickOutside);
},
mounted() {
// mounted
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(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);
},
/**
* 创建车辆图标
*/
createCar(type) {
let _this = this;
this.graphicLayer.clear();
this.graphicLayer.enabledEvent = false; // addGraphic
//
for (let i = 0; i < this.list.length; i++) {
const item = this.list[i];
let graphic = new mars3d.graphic.ModelPrimitive({
id: item.carId,
style: {
url: this.carUrl,
scale: 3,
minimumPixelSize: 20,
silhouette: true,
silhouetteColor: "#0084ff",
silhouetteSize: 2,
pitch: 0,
roll: 0,
label: {
text: item.carPlate,
font_size: 14,
color: "#ffffff",
outline: true,
outlineColor: "#000000",
pixelOffsetY: -30,
visibleDepth: false,
distanceDisplayCondition: true,
distanceDisplayCondition_far: 50000,
distanceDisplayCondition_near: 0,
},
},
// autoMiddleDynamicPosition: true, //
frameRateHeight: 30, //
});
this.graphicLayer.addGraphic(graphic);
this.graphicLayer.enabledEvent = true; //
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 = 15;
this.changePosition(interval);
this.time = setInterval(() => {
this.changePosition(interval);
}, interval * 1000);
},
//
async changePosition(interval) {
let list = await this.carPoint();
this.graphicLayer.eachGraphic((graphic) => {
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
}
});
},
handleClickOutside(event) {
//
if (this.show && !this.$refs.targetElement.contains(event.target)) {
this.show = false;
}
},
toggleSelection(item) {
//
if (this.isSelected(item)) {
this.selectedItems = this.selectedItems.filter(
(selectedItem) => selectedItem !== item
);
} else {
this.selectedItems.push(item);
}
},
isSelected(item) {
//
return this.selectedItems.includes(item);
},
mapLoad(map) {
this.map = map;
this.graphicLayer = new mars3d.layer.GraphicLayer();
map.addLayer(this.graphicLayer);
// this.initTilesetLayer();
this.getCarPoint();
},
/**
* 加载姑苏区三维图层
*/
initTilesetLayer() {
let _this = this;
// ;
const 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(tiles3dLayer);
if (process.env.NODE_ENV === "production") this.chkShadows(true);
tiles3dLayer.on(mars3d.EventType.load, function (event) {
_this.getCarLocation();
});
},
chkShadows(val) {
let _this = this;
this.map.viewer.shadows = val;
if (val) {
setTimeout(function () {
// 沿
_this.map.scene.shadowMap._lightCamera = _this.map.scene.camera;
}, 1500);
}
},
},
};
</script>
<style lang="scss" scoped>
.input-search {
position: absolute;
top: 100px;
left: 50%;
transform: translateX(-50%);
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;
line-height: 32px;
background: #0084ff;
color: #ffffff;
font-size: 14px;
padding: 0 10px;
height: 100%;
border-radius: 0 3px 3px 0;
}
input {
font-size: 14px;
width: 280px;
height: 100%;
border: 1px solid #0084ff;
border-right: 0;
background: #032b57;
padding-left: 6px;
color: #ffffff;
}
input::placeholder {
color: #7c91a8;
}
input:focus-visible {
outline: none;
}
.search-list {
width: 280px;
background: #032b57;
color: #fff;
border: 1px solid #0084ff;
border-top: 0;
& > div {
cursor: pointer;
font-size: 14px;
padding: 10px;
}
& > div:hover {
background: #0084ff;
}
}
}
.video-list {
position: absolute;
bottom: 25px;
left: 50%;
transform: translateX(-50%);
z-index: 50;
padding: 10px;
display: flex;
align-items: center;
border: 1px solid #415367;
border-radius: 10px;
background: rgba(28, 31, 34, 0.6);
}
.multiple {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
z-index: 100;
width: 880px;
height: 80px;
display: flex;
align-items: center;
justify-content: space-between;
background: url("../assets/images/multipleList.png");
background-size: 100% 100%;
padding: 0 220px;
.checkbox {
cursor: pointer;
width: 112px;
height: 32px;
line-height: 32px;
text-align: center;
font-size: 14px;
color: #ffffff;
background: linear-gradient(180deg, #072853 0%, #0079ff 100%);
border: 1px solid #0084ff;
border-radius: 16px;
display: flex;
align-items: center;
justify-content: center;
opacity: 1;
}
.checked {
opacity: 0.5;
}
.btn-icon {
width: 15px;
height: 16px;
margin-right: 10px;
}
}
</style>

@ -27,6 +27,9 @@
</div>
</el-collapse-transition>
</div>
<div class="albuginea" @click="initTilesetLayer()">
{{ show3D ? "关闭" : "开启" }}三维
</div>
<mars-map @mapLoad="mapLoad" :options="options"></mars-map>
<div class="multiple">
<div
@ -36,17 +39,15 @@
:key="index"
>
<img
:src="
isSelected(item)
? require(`../assets/images/${item}-active.png`)
: require(`../assets/images/${item}.png`)
"
:src="require(`../assets/images/${item}.png`)"
alt=""
class="btn-icon"
/>
{{ item }}
</div>
</div>
<!-- <div id="carMarker" style="display: none"></div> -->
</div>
</template>
@ -54,6 +55,8 @@
import MarsMap from "@/components/mars-map";
import { getCarPoint, getCarByCarplate } from "@/api/yunkun/yunkun.js";
import { adjustCanvasSize, changeBorderColor } from "@/utils/carCanvas.js";
export default {
data() {
const basePathUrl = window.basePathUrl || "";
@ -74,19 +77,13 @@ export default {
baseUrl: basePathUrl + "lib/geoJson/tileset.json",
carUrl: basePathUrl + "lib/qiche.gltf",
map: null,
mapLayer: {},
options: {
scene: {
// center: {
// lat: 31.754913,
// lng: 117.248572,
// alt: 6220,
// heading: 357,
// pitch: -31,
// },
center: {
lat: 31.212805,
lng: 120.607156,
alt: 5096.4,
lat: 31.019462,
lng: 120.635502,
alt: 13761.4,
heading: 357.9,
pitch: -31.5,
},
@ -104,25 +101,12 @@ export default {
},
control: {
contextmenu: { preventDefault: false, hasDefault: false },
// contextmenu: { preventDefault: false, hasDefault: false },
},
basemaps: [
// {
// name: "mapbox",
// icon: "img/basemaps/mapboxSatellite.png",
// type: "mapbox",
// username: "sharealex",
// styleId: "cly5i21fn00e901prgq643t4r",
// token:
// "pk.eyJ1Ijoic2hhcmVhbGV4IiwiYSI6ImNsaXNhZmRjbTFhbnczZmxib3h1OW05YXYifQ.PhlKv60ar3K359d8x2yBPw",
// tilesize: 256,
// scaleFactor: false,
// show: false,
// },
],
},
show: false,
showVideo: true,
show3D: false,
};
},
components: { MarsMap },
@ -131,149 +115,212 @@ export default {
//
document.removeEventListener("click", this.handleClickOutside);
},
mounted() {
// mounted
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();
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 {
}
},
async carPoint() {
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);
/**地图渲染完毕 */
mapLoad(map) {
this.map = map;
map.fixedLight = true; // gltf
//
this.mapLayer.car = new mars3d.layer.GraphicLayer();
this.map.addLayer(this.mapLayer.car);
this.createCar();
},
/**
* 创建车辆图标
*/
createCar(type) {
let _this = this;
this.graphicLayer.clear();
this.graphicLayer.enabledEvent = false; // addGraphic
//
for (let i = 0; i < this.list.length; i++) {
const item = this.list[i];
let graphic = new mars3d.graphic.ModelPrimitive({
id: item.carId,
/**创建车辆 */
createCar() {
let list = [
{
name: "001号线_01_早送_守押001_苏E",
position: [120.608163, 31.184288, 13.5],
},
{
name: "002号线_01_维护_守押085_苏E",
position: [120.607528, 31.209201, 11.1],
},
{
name: "临时任务_考试院_守押072_苏E123",
position: [120.657466, 31.220895, 12.7],
},
];
this.mapLayer.car.clear();
this.mapLayer.car.enabledEvent = false; // addGraphic
for (let index = 0; index < list.length; index++) {
let item = list[index];
const graphic = new mars3d.graphic.ModelEntity({
id: `car${index + 1}`,
position: item.position,
style: {
url: this.carUrl,
scale: 3,
minimumPixelSize: 20,
scale: 0.5,
minimumPixelSize: 30,
silhouette: true,
silhouetteColor: "#0084ff",
silhouetteSize: 2,
pitch: 0,
roll: 0,
label: {
text: item.carPlate,
font_size: 14,
color: "#ffffff",
outline: true,
outlineColor: "#000000",
pixelOffsetY: -30,
visibleDepth: false,
distanceDisplayCondition: true,
distanceDisplayCondition_far: 50000,
distanceDisplayCondition_near: 0,
silhouetteColor: "#008cff",
highlight: {
type: "click",
silhouette: true,
silhouetteColor: "#FFB200",
},
},
circle: {
radius: 200,
fill: false,
materialType: mars3d.MaterialType.CircleWave,
materialOptions: {
color: "#FFB200",
count: 2,
speed: 6,
},
},
// autoMiddleDynamicPosition: true, //
frameRateHeight: 30, //
attr: {
index: index + 1,
},
});
this.graphicLayer.addGraphic(graphic);
this.graphicLayer.enabledEvent = true; //
this.mapLayer.car.addGraphic(graphic);
this.mapLayer.car.enabledEvent = true; //
if (type) {
graphic.openHighlight({
scale: 5,
silhouette: true,
silhouetteColor: "#FAAC51",
silhouetteSize: 2,
label: {
outlineColor: "#FAAC51",
graphic.bindPopup(
() => {
let html = `<div id="car${index + 1}" class="carPlate">
<img src="${require(`../assets/images/carType${
index + 1
}.png`)}" class="carType"/>
${item.name}
</div>`;
return html;
},
{
closeButton: false, //
className: "car-page-popup",
pointerEvents: false, //DIVfalse穿
closeOnClick: false, //Map
autoClose: false, //
toggle: false, //Popup
}
);
graphic.openPopup();
graphic.on(mars3d.EventType.highlightOpen, (e) => {
e.target.setOptions({
//
circle: {
fill: true,
},
});
}
graphic.on(mars3d.EventType.click, function (e) {
_this.$router.push({
this.handleCarActive({
id: e.target._id,
color: "#FFB200",
image: require(`../assets/images/carType${e.target.attr.index}-s.png`),
});
});
graphic.on(mars3d.EventType.highlightClose, (e) => {
e.target.setOptions({
circle: {
fill: false,
},
});
this.handleCarActive({
id: e.target._id,
color: "#008cff",
image: require(`../assets/images/carType${e.target.attr.index}.png`),
});
});
graphic.on(mars3d.EventType.click, (e) => {
this.$router.push({
path: "/carInfo",
query: { carId: e.target.id },
// query: { carId: e.target.id },
});
});
// //
// this.changePosition(0);
// // setInterval
// const interval = 30;
// this.changePosition(interval);
// this.time = setInterval(() => {
// this.changePosition(interval);
// }, interval * 1000);
}
this.changePosition(0);
// setInterval
const interval = 15;
this.changePosition(interval);
this.time = setInterval(() => {
this.changePosition(interval);
}, interval * 1000);
},
//
async changePosition(interval) {
let list = await this.carPoint();
this.graphicLayer.eachGraphic((graphic) => {
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
}
changePosition(time) {
this.mapLayer.car.eachGraphic((graphic) => {
graphic.addDynamicPosition(this.randomPoint(), time); // time
});
},
handleClickOutside(event) {
//
if (this.show && !this.$refs.targetElement.contains(event.target)) {
this.show = false;
}
randomPoint() {
const jd = this.random(120.2 * 1000, 120.9 * 1000) / 1000;
const wd = this.random(30.9 * 1000, 31.6 * 1000) / 1000;
return Cesium.Cartesian3.fromDegrees(jd, wd, 30);
},
random(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
},
/**
* 处理车辆被选中
*/
handleCarActive(data) {
let carItem = document.getElementById(data.id);
let carIcon = carItem.getElementsByClassName("carType")[0];
carIcon.src = data.image;
carItem.style.borderColor = data.color;
},
/**搜索 */
handleSearch() {
this.searchList = [
{
carName: "002号线_01_维护_守押085_苏E",
position: [120.607528, 31.209201, 11.1],
},
];
this.show = !this.show;
},
/**单击搜索结果 */
handelLookCar(item) {
let carItem = this.mapLayer.car.getGraphicById(`car2`);
carItem.openHighlight();
this.map.flyToPoint(item.position, {
radius: 3788,
});
this.show = !this.show;
},
toggleSelection(item) {
//
if (this.isSelected(item)) {
@ -288,64 +335,37 @@ export default {
//
return this.selectedItems.includes(item);
},
mapLoad(map) {
this.map = map;
this.graphicLayer = new mars3d.layer.GraphicLayer();
map.addLayer(this.graphicLayer);
// this.initTilesetLayer();
this.getCarPoint();
},
/**
* 加载姑苏区三维图层
*/
initTilesetLayer() {
let _this = this;
// ;
const 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(tiles3dLayer);
if (process.env.NODE_ENV === "production") this.chkShadows(true);
tiles3dLayer.on(mars3d.EventType.load, function (event) {
_this.getCarLocation();
});
},
chkShadows(val) {
let _this = this;
this.map.viewer.shadows = val;
if (val) {
setTimeout(function () {
// 沿
_this.map.scene.shadowMap._lightCamera = _this.map.scene.camera;
}, 1500);
}
},
},
};
</script>
<style lang="scss" scoped>
.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;
}
.albuginea:hover {
background: #0084ff;
}
.input-search {
position: absolute;
top: 23px;
top: 103px;
left: 50%;
transform: translateX(-50%);
z-index: 100;
.search-box {
position: relative;
display: flex;
@ -417,10 +437,10 @@ export default {
}
.multiple {
position: absolute;
bottom: 0;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
z-index: 50;
z-index: 100;
width: 880px;
height: 80px;
display: flex;
@ -428,7 +448,7 @@ export default {
justify-content: space-between;
background: url("../assets/images/multipleList.png");
background-size: 100% 100%;
padding: 0 230px;
padding: 0 220px;
.checkbox {
cursor: pointer;
width: 112px;
@ -438,19 +458,15 @@ export default {
font-size: 14px;
color: #ffffff;
background: linear-gradient(180deg, #072853 0%, #0079ff 100%);
// border-radius: 16px;
border: 1px solid #0084ff;
border-radius: 16px;
display: flex;
align-items: center;
justify-content: center;
opacity: 1;
}
.checked {
background: #fd873f;
color: #612500;
border: 0;
font-weight: bold;
border: 1px solid #f7c75d;
opacity: 0.5;
}
.btn-icon {
width: 15px;

@ -0,0 +1,400 @@
<template>
<div class="map-container">
<div class="container-top">
<div class="next-stand">
<img src="../assets/images/next.png" alt="" />
<span>0</span>
</div>
<div class="real-time">
<img src="../assets/images/realTime.png" alt="" />
<span>{{ mileData.mile ? ileData.mile : 0 }}</span>
</div>
</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";
import { historyLine, carMidle } from "@/api/yunkun/yunkun.js";
export default {
data() {
const basePathUrl = window.basePathUrl || "";
return {
list: [],
mileData: {
mile: "", //
},
queryParams: {
startTime: undefined,
endTime: undefined,
},
graphicLayer: null,
baseUrl: basePathUrl + "lib/geoJson/tileset.json",
map: null,
options: {
scene: {
center: {
lat: 31.212805,
lng: 120.607156,
alt: 5096.4,
heading: 357.9,
pitch: -31.5,
},
},
control: {
contextmenu: { preventDefault: false, hasDefault: false },
},
},
carUrl: basePathUrl + "lib/qiche.gltf",
};
},
components: { MarsMap, grids },
beforeDestroy() {},
mounted() {
const { startOfDay, endOfDay } = this.getStartAndEndOfDayFormatted(true);
this.queryParams = {
carId: this.$route.query.carId,
startTime: startOfDay,
endTime: endOfDay,
};
this.getCarMidle();
},
methods: {
mapLoad(map) {
this.map = map;
this.graphicLayer = new mars3d.layer.GraphicLayer();
map.addLayer(this.graphicLayer);
// this.initTilesetLayer();
this.getCarHistoryLine();
},
/**根据车辆的id获取车辆的历史轨迹 */
async getCarHistoryLine() {
let result = await historyLine(this.queryParams);
result.list.map((item) => {
this.list.push([parseFloat(item.lng), parseFloat(item.lat)]);
});
this.historyLine();
this.createCar(result.countData.avg_speed);
},
historyLine() {
const firstPoint = this.list[0];
const divGraphic = new mars3d.graphic.DivGraphic({
position: firstPoint,
style: {
html: `<div class="mars-four-color mars3d-animation">
<div class="four-color_name">起点</div>
</div>`,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
distanceDisplayCondition: true,
clampToGround: true,
visibleDepth: true,
},
});
this.graphicLayer.addGraphic(divGraphic);
const graphic = new mars3d.graphic.PolylineEntity({
positions: this.list,
style: {
width: 10,
color: "#00F7AC",
outline: true,
outlineColor: "#008DF8",
outlineWidth: 5,
clampToGround: true,
},
});
this.graphicLayer.addGraphic(graphic);
},
/**获取车辆天里程 */
async getCarMidle() {
const { startOfDay, endOfDay } = this.getStartAndEndOfDayFormatted();
let result = await carMidle({
carId: this.queryParams.carId,
startDate: startOfDay,
endDate: endOfDay,
});
this.mileData.mile = result.mile;
},
getStartAndEndOfDayFormatted(boole) {
const now = new Date();
const startOfDay = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate(),
0,
0,
0
);
const endOfDay = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate(),
23,
59,
59,
999
);
return {
startOfDay: this.formatDate(startOfDay, boole),
endOfDay: this.formatDate(endOfDay, boole),
};
},
formatDate(date, boole) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0"); // 01
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
if (boole) {
return `${year}${month}${day}${hours}${minutes}${seconds}`;
} else {
return `${year}${month}${day}`;
}
},
/**
* 加载姑苏区三维图层
*/
initTilesetLayer() {
let _this = this;
// ;
let 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(tiles3dLayer);
tiles3dLayer.on(mars3d.EventType.load, function (event) {
_this.createCar();
});
},
/**
* 生成车辆实时点位
*/
async createCar(avg_speed) {
let _this = this;
const lastPoint = this.list[this.list.length - 1];
// let res = await getCarIdInfo("1328CC51-C858-4FFA-8714-4F354BB49CF8");
const fixedRoute = new mars3d.graphic.FixedRoute({
name: "贴模型表面漫游",
speed: avg_speed, //
positions: [lastPoint],
camera: {
type: "gs",
heading: 90,
radius: 500,
},
model: {
show: true,
url: _this.carUrl,
scale: 0.3,
minimumPixelSize: 55,
silhouette: true,
silhouetteColor: "#fff",
silhouetteSize: 1,
silhouetteAlpha: 0.19,
clampToGround: true,
},
// billboard: {
// image: require("../assets/images/car-active.png"),
// width: 210,
// height: 100,
// horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //
// verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
// distanceDisplayCondition: true,
// clampToGround: true,
// visibleDepth: true,
// label: {
// text: "001线_01__001_E",
// color: "#fff",
// font_size: 13,
// pixelOffsetY: -81,
// pixelOffsetX: 10,
// horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
// distanceDisplayCondition: true,
// visibleDepth: false,
// },
// },
circle: {
radius: 500,
materialType: mars3d.MaterialType.CircleWave,
materialOptions: {
color: "#FAAC51",
count: 2,
speed: 10,
},
clampToTileset: true,
},
// polyline: {
// // lastMaterialType: "LineTrail",
// width: 10,
// // closure: true,
// color: "#00F7AC",
// outline: true,
// outlineColor: "#008DF8",
// outlineWidth: 5,
// clampToGround: true,
// // materialOptions: {
// // color: "#008BFA",
// // materialType: "LineTrail",
// // speed: 0,
// // },
// // materialType: "LineTrail",
// // },
// },
});
this.graphicLayer.addGraphic(fixedRoute);
//
// this.bindPopup(fixedRoute, res.data);
//
// fixedRoute.start();
//
// fixedRoute.openPopup();
// // //
},
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">
<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,
offsetY: 20,
// closeButton: false,
});
},
chkShadows(val) {
let _this = this;
this.map.viewer.shadows = val;
if (val) {
setTimeout(function () {
// 沿
_this.map.scene.shadowMap._lightCamera = _this.map.scene.camera;
}, 1500);
}
},
},
};
</script>
<style lang="scss" scoped>
.container-top {
position: fixed;
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>

@ -3,13 +3,19 @@
<div class="container-top">
<div class="next-stand">
<img src="../assets/images/next.png" alt="" />
<span>10.8</span>
<span>0</span>
</div>
<div class="real-time">
<img src="../assets/images/realTime.png" alt="" />
<span>{{ mileData.mile }}</span>
<span>{{ mileData.mile ? ileData.mile : 0 }}</span>
</div>
</div>
<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>
@ -26,7 +32,6 @@ export default {
data() {
const basePathUrl = window.basePathUrl || "";
return {
list: [],
mileData: {
mile: "", //
},
@ -34,92 +39,101 @@ export default {
startTime: undefined,
endTime: undefined,
},
graphicLayer: null,
baseUrl: basePathUrl + "lib/geoJson/tileset.json",
map: null,
mapLayer: {},
show3D: false,
options: {
scene: {
center: {
lat: 31.212805,
lng: 120.607156,
alt: 5096.4,
lat: 31.184348,
lng: 120.625126,
alt: 6764.6,
heading: 357.9,
pitch: -31.5,
},
},
control: {
contextmenu: { preventDefault: false, hasDefault: false },
// contextmenu: { preventDefault: false, hasDefault: false },
},
basemaps: [
{
name: "mapbox影像图",
icon: "img/basemaps/mapboxSatellite.png",
type: "mapbox",
username: "sharealex",
styleId: "cly5i21fn00e901prgq643t4r",
token:
"pk.eyJ1Ijoic2hhcmVhbGV4IiwiYSI6ImNsaXNhZmRjbTFhbnczZmxib3h1OW05YXYifQ.PhlKv60ar3K359d8x2yBPw",
tilesize: 256,
scaleFactor: false,
show: false,
},
],
},
Line: [],
carUrl: basePathUrl + "lib/qiche.gltf",
};
},
components: { MarsMap, grids },
beforeDestroy() {},
mounted() {
const { startOfDay, endOfDay } = this.getStartAndEndOfDayFormatted(true);
this.queryParams = {
carId: this.$route.query.carId,
startTime: startOfDay,
endTime: endOfDay,
};
this.getCarMidle();
},
created() {},
methods: {
/**地图渲染完毕 */
mapLoad(map) {
this.map = map;
this.graphicLayer = new mars3d.layer.GraphicLayer();
map.addLayer(this.graphicLayer);
// this.initTilesetLayer();
this.getCarHistoryLine();
},
map.fixedLight = true; // gltf
//
this.mapLayer.Line = new mars3d.layer.GraphicLayer();
this.map.addLayer(this.mapLayer.Line);
/**根据车辆的id获取车辆的历史轨迹 */
async getCarHistoryLine() {
let result = await historyLine(this.queryParams);
result.list.map((item) => {
this.list.push([parseFloat(item.lng), parseFloat(item.lat)]);
});
this.mapLayer.car = new mars3d.layer.GraphicLayer();
this.map.addLayer(this.mapLayer.car);
this.historyLine();
this.createCar(result.countData.avg_speed);
this.createLine();
this.createCar();
},
historyLine() {
const firstPoint = this.list[0];
const divGraphic = new mars3d.graphic.DivGraphic({
position: firstPoint,
/**
* 加载姑苏区三维图层
*/
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: {
html: `<div class="mars-four-color mars3d-animation">
<div class="four-color_name">起点</div>
</div>`,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //
image: require("../assets/images/origin.png"),
scale: 1,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
distanceDisplayCondition: true,
clampToGround: true,
visibleDepth: true,
pixelOffsetY: 5,
},
});
this.graphicLayer.addGraphic(divGraphic);
this.mapLayer.Line.addGraphic(marker);
const graphic = new mars3d.graphic.PolylineEntity({
positions: this.list,
const line = new mars3d.graphic.PolylineEntity({
positions: this.Line,
style: {
width: 10,
color: "#00F7AC",
@ -129,173 +143,66 @@ export default {
clampToGround: true,
},
});
this.graphicLayer.addGraphic(graphic);
},
/**获取车辆天里程 */
async getCarMidle() {
const { startOfDay, endOfDay } = this.getStartAndEndOfDayFormatted();
let result = await carMidle({
carId: this.queryParams.carId,
startDate: startOfDay,
endDate: endOfDay,
});
this.mileData.mile = result.mile;
},
getStartAndEndOfDayFormatted(boole) {
const now = new Date();
const startOfDay = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate(),
0,
0,
0
);
const endOfDay = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate(),
23,
59,
59,
999
);
return {
startOfDay: this.formatDate(startOfDay, boole),
endOfDay: this.formatDate(endOfDay, boole),
};
},
formatDate(date, boole) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0"); // 01
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
this.mapLayer.Line.addGraphic(line);
if (boole) {
return `${year}${month}${day}${hours}${minutes}${seconds}`;
} else {
return `${year}${month}${day}`;
}
//
},
/**
* 加载姑苏区三维图层
*/
initTilesetLayer() {
let _this = this;
// ;
let 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(tiles3dLayer);
tiles3dLayer.on(mars3d.EventType.load, function (event) {
_this.createCar();
});
},
/**
* 生成车辆实时点位
*/
async createCar(avg_speed) {
let _this = this;
const lastPoint = this.list[this.list.length - 1];
// let res = await getCarIdInfo("1328CC51-C858-4FFA-8714-4F354BB49CF8");
const fixedRoute = new mars3d.graphic.FixedRoute({
name: "贴模型表面漫游",
speed: avg_speed, //
positions: [lastPoint],
camera: {
type: "gs",
heading: 90,
radius: 500,
},
//
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,
// },
model: {
show: true,
url: _this.carUrl,
scale: 0.3,
minimumPixelSize: 55,
url: this.carUrl,
scale: 0.5,
minimumPixelSize: 30,
silhouette: true,
silhouetteColor: "#fff",
silhouetteSize: 1,
silhouetteAlpha: 0.19,
clampToGround: true,
silhouetteColor: "#FFB200",
},
// billboard: {
// image: require("../assets/images/car-active.png"),
// width: 210,
// height: 100,
// horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //
// verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
// distanceDisplayCondition: true,
// clampToGround: true,
// visibleDepth: true,
// label: {
// text: "001线_01__001_E",
// color: "#fff",
// font_size: 13,
// pixelOffsetY: -81,
// pixelOffsetX: 10,
// horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
// distanceDisplayCondition: true,
// visibleDepth: false,
// },
// },
circle: {
radius: 500,
radius: 200,
materialType: mars3d.MaterialType.CircleWave,
materialOptions: {
color: "#FAAC51",
color: "#FFB200",
count: 2,
speed: 10,
speed: 6,
},
clampToTileset: true,
},
// polyline: {
// // lastMaterialType: "LineTrail",
// width: 10,
// // closure: true,
// color: "#00F7AC",
// outline: true,
// outlineColor: "#008DF8",
// outlineWidth: 5,
// clampToGround: true,
// // materialOptions: {
// // color: "#008BFA",
// // materialType: "LineTrail",
// // speed: 0,
// // },
// // materialType: "LineTrail",
// // },
// },
polyline: {
width: 10,
color: "#00F7AC",
outline: true,
outlineColor: "#008DF8",
outlineWidth: 5,
clampToGround: true,
},
});
this.graphicLayer.addGraphic(fixedRoute);
//
// this.bindPopup(fixedRoute, res.data);
//
// fixedRoute.start();
//
// fixedRoute.openPopup();
// // //
this.mapLayer.car.addGraphic(car);
let res = await getCarIdInfo("1328CC51-C858-4FFA-8714-4F354BB49CF8");
this.bindPopup(car, res.data);
car.openPopup();
car.start();
},
//
bindPopup(fixedRoute, data) {
const userList = data.userList.map((item) => {
return `<div class="popup-item">
@ -312,6 +219,7 @@ export default {
});
let html = `<div class="diy-popup">
<div class="pointer"></div>
<div class="popup-title">001号线_01_早送_守押<br/>
001_苏E12345
</div>
@ -339,29 +247,41 @@ export default {
fixedRoute.bindPopup(html, {
className: "carPopup",
offsetX: 280,
offsetY: 20,
offsetY: 100,
// closeButton: false,
});
},
chkShadows(val) {
let _this = this;
this.map.viewer.shadows = val;
if (val) {
setTimeout(function () {
// 沿
_this.map.scene.shadowMap._lightCamera = _this.map.scene.camera;
}, 1500);
}
},
},
};
</script>
<style lang="scss" scoped>
.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;
top: 23px;
top: 100px;
left: 50%;
transform: translateX(-50%);
z-index: 100;

@ -22,18 +22,18 @@
<script>
import MarsMap from "@/components/mars-map";
import { getAreaData } from "@/api/yunkun/index.js";
import { circle } from "leaflet";
export default {
data() {
const basePathUrl = window.basePathUrl || "";
return {
currentIndex: null,
map: null,
options: {
scene: {
center: {
lat: 29.812141,
lng: 120.170808,
alt: 129994.6,
lat: 29.689932,
lng: 120.127589,
alt: 146960.4,
heading: 9.5,
pitch: -46.2,
},
@ -56,313 +56,320 @@ export default {
},
],
},
map: null,
suzhouLayer: null,
rimCity: null,
mapLayer: {},
rongheUrl: basePathUrl + "lib/ronghe.json",
suzhouUrl: basePathUrl + "lib/suzhou.json",
rimCityUrl: basePathUrl + "lib/nearbyCity.json",
rongheUrl: basePathUrl + "lib/ronghe.json",
list: [],
multipleList: ["线路总数", "营业网点", "上门收款点", "ATM机"],
selectedItems: [],
currentIndex: null,
layerzIndex: {
相城区: 60,
姑苏区: 60,
虎丘区: 60,
工业园区: 40,
吴中区: 60,
吴江区: 40,
},
};
},
components: {
MarsMap,
},
mounted() {},
created() {
this.getAreaData();
},
methods: {
mapLoad(map) {
this.map = map;
toggleSelection(item) {
//
if (this.isSelected(item)) {
this.selectedItems = this.selectedItems.filter(
(selectedItem) => selectedItem !== item
);
} else {
this.selectedItems.push(item);
}
if (this.currentIndex == null) return;
const markerItme = document
.getElementById(`marker${this.currentIndex}`)
.getElementsByClassName("row-item");
// - - -
map.setSceneOptions({
cameraController: {
enableZoom: false,
enableTranslate: false,
enableRotate: false,
enableTilt: false,
},
for (let i = 0; i < this.multipleList.length; i++) {
markerItme[i].style.display = "block";
}
this.handlerhidle(markerItme);
},
//
handlerhidle(cell) {
this.selectedItems.forEach((item) => {
let itemIndex = this.multipleList.findIndex((it) => it == item);
if (itemIndex > -1) {
cell[itemIndex].style.display = "none";
}
});
//
this.suzhouLayer = new mars3d.layer.GraphicLayer({ zIndex: 10 });
map.addLayer(this.suzhouLayer);
//
this.rimCity = new mars3d.layer.GraphicLayer({ zIndex: 9 });
map.addLayer(this.rimCity);
this.initSuzhou();
},
isSelected(item) {
//
return this.selectedItems.includes(item);
},
async getAreaData() {
let res = await getAreaData();
this.list = res.data;
},
mapLoad(map) {
this.map = map;
if (process.env.NODE_ENV === "production") {
map.setSceneOptions({
cameraController: {
enableZoom: false,
enableTranslate: false,
enableRotate: false,
enableTilt: false,
},
});
}
//
this.createMapLayer();
//
this.addAreaLayer();
//
this.addRonghe();
this.addScale();
//
this.initRimcity();
},
initRimcity() {
mars3d.Util.fetchJson({ url: this.rimCityUrl }).then((res) => {
const arr = mars3d.Util.geoJsonToGraphics(res);
arr.map((item, index) => {
const polygonEntity = new mars3d.graphic.PolygonEntity({
positions: item.positions,
style: {
fill: true,
color: "#101A2E",
opacity: 0.5,
outline: true,
outlineWidth: 2,
outlineColor: "#28334A",
clampToGround: true,
// hasShadows: true,
label: {
text: item.attr.name,
position: "center",
font_size: 18,
color: "#283F61",
// font_family: "",
outline: true,
outlineColor: "black",
outlineWidth: 1,
//
scaleByDistance: true,
scaleByDistance_far: 20000000,
scaleByDistance_farValue: 0.1,
scaleByDistance_near: 1000,
scaleByDistance_nearValue: 1,
},
},
});
createMapLayer() {
//
this.mapLayer.rim = new mars3d.layer.GraphicLayer();
this.map.addLayer(this.mapLayer.area);
this.rimCity.addGraphic(polygonEntity);
});
//
this.mapLayer.marker = new mars3d.layer.GraphicLayer();
this.map.addLayer(this.mapLayer.marker);
//
this.mapLayer.area = new mars3d.layer.GraphicLayer();
this.map.addLayer(this.mapLayer.area);
},
async addRonghe() {
//
let mapData = await mars3d.Util.fetchJson({ url: this.rongheUrl });
const arr = mars3d.Util.geoJsonToGraphics(mapData);
const polygonEntity = new mars3d.graphic.PolygonEntity({
positions: arr[0].positions,
style: {
fill: true,
materialType: "Image",
materialOptions: {
image: require("../assets/images/map-bg.jpg"),
},
outline: true,
outlineWidth: 4,
outlineColor: "#00D1FF",
},
});
this.mapLayer.area.addGraphic(polygonEntity);
//
const wall = new mars3d.graphic.WallPrimitive({
positions: arr[0].positions,
style: {
setHeight: -20000,
diffHeight: 20000, //
width: 10,
materialType: mars3d.MaterialType.Image2,
materialOptions: {
image: require("../assets/images/fence-top.png"),
color: "#0071F8",
},
},
});
this.mapLayer.area.addGraphic(wall);
},
async initSuzhou() {
let _this = this;
this.addWall();
let list = await this.getAreaData();
mars3d.Util.fetchJson({ url: this.suzhouUrl }).then((res) => {
const arr = mars3d.Util.geoJsonToGraphics(res); // geojson
arr.map((item, index) => {
let popupItem = list.filter((it) => it.area == item.attr.name);
const polygonEntity = new mars3d.graphic.PolygonEntity({
positions: item.positions,
id: `city${index}`,
style: {
fill: true,
color: "#4881a7",
opacity: 0.9,
outline: true,
outlineWidth: 2,
outlineColor: "#00BEFF",
highlight: {
type: "click",
color: "#003EFF",
opacity: 0.5,
outlineColor: "#00B0FF",
},
async addAreaLayer() {
let mapData = await mars3d.Util.fetchJson({ url: this.suzhouUrl });
const arr = mars3d.Util.geoJsonToGraphics(mapData);
for (let i = 0; i < arr.length; i++) {
const item = arr[i];
const index = i + 1;
console.log(item);
const polygonEntity = new mars3d.graphic.PolygonEntity({
id: index,
positions: item.positions,
style: {
fill: true,
color: "#001C54",
opacity: 0.5,
outline: true,
outlineWidth: 2,
outlineColor: "#00BEFF",
highlight: {
type: "click",
color: "#003EFF",
opacity: 0.6,
outlineColor: "#00B0FF",
},
attr: {
...item.attr,
...{ index: index },
...(popupItem.length > 0 ? popupItem[0] : {}),
},
attr: item.attr,
});
this.addMarker(item.attr.x, item.attr.y, item.attr.name, index);
//;
polygonEntity.on(mars3d.EventType.highlightOpen, (e) => {
this.handlerMarkerHighlight(true, e.target.id);
const circleItem = this.mapLayer.marker.getGraphicById(
`circle${e.target.id}`
);
circleItem.openHighlight({
materialOptions: {
color: "#FD873F",
},
});
this.suzhouLayer.addGraphic(polygonEntity);
this.addCenterGraphi(polygonEntity.attr, index);
//
polygonEntity.on(mars3d.EventType.highlightOpen, function (e) {
_this.currentIndex = e.target.options.attr.index;
let circleIndex = _this.suzhouLayer.getGraphicByAttr(
`circle${e.target.options.attr.index}`
);
circleIndex.openHighlight({
materialOptions: {
color: "#FAAC51",
},
});
_this.updateIamge(index, true);
});
//
polygonEntity.on(mars3d.EventType.highlightClose, function (e) {
_this.currentIndex = null;
let circleIndex = _this.suzhouLayer.getGraphicByAttr(
`circle${e.target.options.attr.index}`
);
circleIndex.closeHighlight();
_this.updateIamge(index);
});
this.currentIndex = e.target.id;
});
//
polygonEntity.on(mars3d.EventType.highlightClose, (e) => {
this.handlerMarkerHighlight(false, e.target.id);
const circleItem = this.mapLayer.marker.getGraphicById(
`circle${e.target.id}`
);
circleItem.closeHighlight();
this.currentIndex = null;
});
//
this.addScale();
});
},
//
async getAreaData() {
let res = await getAreaData();
return res.data;
this.mapLayer.area.addGraphic(polygonEntity);
}
},
addCenterGraphi(attr, index) {
let obj = {
相城区: 60,
姑苏区: 60,
虎丘区: 60,
工业园区: 40,
吴中区: 40,
吴江区: 40,
};
addMarker(lng, lat, name, id) {
let areaItem = this.list.filter((item) => item.area == name);
if (areaItem.length <= 0) return;
//
const circleGraphic = new mars3d.graphic.CircleEntity({
id: `circle${attr.index}`,
position: new mars3d.LngLatPoint(attr.x, attr.y),
position: new mars3d.LngLatPoint(lng, lat),
id: `circle${id}`,
style: {
radius: 3500,
radius: 4200,
materialType: mars3d.MaterialType.CircleWave,
materialOptions: {
color: "#60DAEB",
color: "#5CD2E6",
count: 2,
speed: 10,
},
},
allowDrillPick: true, //穿
});
this.suzhouLayer.addGraphic(circleGraphic);
const divGraphic = new mars3d.graphic.DivGraphic({
position: new mars3d.LngLatPoint(attr.x, attr.y),
id: `areaName${attr.index}`,
zIndex: obj[attr.name],
style: {
html: `<div class="mars-four-color mars3d-animation" id="areaName${attr.index}">
<div class="four-color_name">${attr.name}</div>
<div class="screen-list">
this.mapLayer.marker.addGraphic(circleGraphic);
let html = `<div class="mars-four-color">
<div class="four-color_name">${areaItem[0].area}</div>
<div class="screen-list">
<div class="row-item">
<div class="lable-value">
<div class="lable-data">线路总数</div>
<div class="value-data">${attr.lineNum} <span></span></div>
<div class="value-data">${areaItem[0].lineNum} <span></span></div>
</div>
</div>
<div class="row-item">
<div class="lable-value">
<div class="lable-data">营业网点</div>
<div class="value-data">${attr.yywdzs} <span></span></div>
<div class="value-data">${areaItem[0].yywdzs} <span></span></div>
</div>
</div>
<div class="row-item">
<div class="lable-value">
<div class="lable-data">上门收款点</div>
<div class="value-data">${attr.skdNum} <span></span></div>
<div class="value-data">${areaItem[0].skdNum} <span></span></div>
</div>
</div>
<div class="row-item">
<div class="lable-value">
<div class="lable-data">ATM机</div>
<div class="value-data">${attr.atmNum} <span></span></div>
<div class="value-data">${areaItem[0].atmNum} <span></span></div>
</div>
</div>
</div>
</div>`,
</div>`;
const divGraphic = new mars3d.graphic.DivGraphic({
id: `marker${id}`,
position: new mars3d.LngLatPoint(lng, lat),
zIndex: this.layerzIndex[areaItem[0].area],
style: {
html: html,
horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
verticalOrigin: Cesium.VerticalOrigin.CENTER,
clampToGround: true,
scaleByDistance: true,
},
attr,
show: true,
});
this.suzhouLayer.addGraphic(divGraphic);
this.mapLayer.marker.addGraphic(divGraphic);
},
//
addWall() {
mars3d.Util.fetchJson({ url: this.rongheUrl }).then((res) => {
const arr = mars3d.Util.geoJsonToGraphics(res);
const options = arr[0];
const polygonEntity = new mars3d.graphic.PolygonEntity({
positions: options.positions,
style: {
fill: true,
materialType: "Image",
image: require("../assets/images/areaBg.png"),
stRotationDegree: -35,
},
});
this.suzhouLayer.addGraphic(polygonEntity);
//
const wall = new mars3d.graphic.WallPrimitive({
positions: options.positions,
style: {
setHeight: -20000,
diffHeight: 20000, //
width: 10,
materialType: mars3d.MaterialType.Image2,
materialOptions: {
image: require("../assets/images/fence-top.png"),
color: "#0071F8",
},
},
});
this.suzhouLayer.addGraphic(wall);
});
},
//div
updateIamge(index, type) {
let imageBox = document.getElementById(`areaName${index}`);
let img = imageBox.getElementsByClassName("four-color_name")[0];
let screenList = imageBox.getElementsByClassName("screen-list")[0];
let lableValue = screenList.getElementsByClassName("row-item");
if (type) {
img.style.background = `url( ${require("@/assets/images/areaName_active.png")})`;
img.style.backgroundSize = "100% 100%";
img.style.color = "#612500";
this.selectedItems.forEach((item) => {
let itemIndex = this.multipleList.findIndex((it) => it == item);
if (itemIndex > -1) {
lableValue[itemIndex].style.display = "none";
}
});
screenList.style.opacity = 1;
//marker
handlerMarkerHighlight(boole, id) {
const markerItme = document.getElementById(`marker${id}`);
const bg = markerItme.getElementsByClassName("four-color_name")[0];
const cell = markerItme.getElementsByClassName("row-item");
if (boole) {
bg.style.color = "#612500";
bg.style.background = `url( ${require("@/assets/images/areaName_active.png")})`;
bg.style.backgroundSize = "100% 100%";
for (let i = 0; i < this.multipleList.length; i++) {
cell[i].style.display = "block";
}
this.handlerhidle(cell);
} else {
img.style.background = `url( ${require("@/assets/images/areaName.png")})`;
img.style.backgroundSize = "100% 100%";
img.style.color = "#fff250";
screenList.style.opacity = 0;
for (let i = 0; i < lableValue.length; i++) {
lableValue[i].style.display = "block";
bg.style.color = "#fff250";
bg.style.background = `url( ${require("@/assets/images/areaName.png")})`;
bg.style.backgroundSize = "100% 100%";
for (let i = 0; i < this.multipleList.length; i++) {
cell[i].style.display = "none";
}
}
},
toggleSelection(item) {
//
if (this.isSelected(item)) {
this.selectedItems = this.selectedItems.filter(
(selectedItem) => selectedItem !== item
);
} else {
this.selectedItems.push(item);
}
//
initRimcity() {
mars3d.Util.fetchJson({ url: this.rimCityUrl }).then((res) => {
const arr = mars3d.Util.geoJsonToGraphics(res);
arr.map((item, index) => {
const polygonEntity = new mars3d.graphic.PolygonEntity({
positions: item.positions,
style: {
fill: true,
color: "#101A2E",
opacity: 0.5,
outline: true,
outlineWidth: 2,
outlineColor: "#28334A",
clampToGround: true,
// hasShadows: true,
label: {
text: item.attr.name,
position: "center",
font_size: 18,
color: "#283F61",
// font_family: "",
outline: true,
outlineColor: "black",
outlineWidth: 1,
//
scaleByDistance: true,
scaleByDistance_far: 20000000,
scaleByDistance_farValue: 0.1,
scaleByDistance_near: 1000,
scaleByDistance_nearValue: 1,
},
},
});
if (this.currentIndex == null) return;
let imageBox = document.getElementById(`areaName${this.currentIndex}`);
let screenList = imageBox.getElementsByClassName("screen-list")[0];
let lableValue = screenList.getElementsByClassName("row-item");
screenList.style.opacity = 0;
for (let i = 0; i < this.multipleList.length; i++) {
lableValue[i].style.display = "block";
}
this.selectedItems.forEach((item) => {
let itemIndex = this.multipleList.findIndex((it) => it == item);
if (itemIndex > -1) {
lableValue[itemIndex].style.display = "none";
}
this.mapLayer.area.addGraphic(polygonEntity);
});
});
screenList.style.opacity = 1;
},
isSelected(item) {
//
return this.selectedItems.includes(item);
},
addScale() {
const graphic = new mars3d.graphic.RectanglePrimitive({
positions: [
[119.850928, 31.133555, 99.4],
[120.312769, 30.673795, -26.3],
[120.595427, 30.503904, -9.1],
[120.900807, 30.516725, -12.5],
[119.924698, 31.029796, 13.9],
[120.305187, 30.567241, -7.4],
[120.862246, 30.817488, -27.2],
],
style: {
materialType: mars3d.MaterialType.Image2,
@ -373,7 +380,7 @@ export default {
flat: true,
},
});
this.suzhouLayer.addGraphic(graphic);
this.mapLayer.area.addGraphic(graphic);
},
},
};
@ -385,48 +392,44 @@ export default {
width: 100%;
height: 100%;
overflow: hidden;
}
.multiple {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
z-index: 100;
width: 880px;
height: 80px;
display: flex;
align-items: center;
justify-content: space-between;
background: url("../assets/images/multipleList.png");
background-size: 100% 100%;
padding: 0 180px;
.checkbox {
cursor: pointer;
width: 112px;
height: 32px;
line-height: 32px;
text-align: center;
font-size: 14px;
color: #ffffff;
background: linear-gradient(180deg, #072853 0%, #0079ff 100%);
// border-radius: 16px;
border: 1px solid #0084ff;
border-radius: 16px;
.multiple {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
z-index: 100;
width: 880px;
height: 80px;
display: flex;
align-items: center;
justify-content: center;
}
.checked {
background: #fd873f;
color: #612500;
border: 0;
font-weight: bold;
border: 1px solid #f7c75d;
}
.btn-icon {
width: 15px;
height: 16px;
margin-right: 10px;
justify-content: space-between;
background: url("../assets/images/multipleList.png");
background-size: 100% 100%;
padding: 0 180px;
.checkbox {
cursor: pointer;
width: 112px;
height: 32px;
line-height: 32px;
text-align: center;
font-size: 14px;
color: #ffffff;
background: linear-gradient(180deg, #072853 0%, #0079ff 100%);
border: 1px solid #0084ff;
border-radius: 16px;
display: flex;
align-items: center;
justify-content: center;
opacity: 1;
}
.checked {
opacity: 0.5;
}
.btn-icon {
width: 15px;
height: 16px;
margin-right: 10px;
}
}
}
</style>

@ -0,0 +1,390 @@
<template>
<div class="map-container">
<div class="extend-box">
<div class="sub-title"></div>
<div class="data-total">{{ total }}</div>
</div>
<mars-map @mapLoad="mapLoad" :options="options"></mars-map>
</div>
</template>
<script>
import point1 from "@/assets/images/levelcity.png";
import point2 from "@/assets/images/province.png";
import linePoint1 from "@/assets/images/linePoint1.png";
import linePoint2 from "@/assets/images/linePoint2.png";
import MarsMap from "@/components/mars-map";
// import province from "@/assets/images/province.png";
import { getProvince } from "@/api/yunkun/index.js";
export default {
data() {
const basePathUrl = window.basePathUrl || "";
return {
cityAttr: {},
total: 0,
options: {
scene: {
center: {
lat: -9.65789,
lng: 110.718514,
alt: 13807610.5,
heading: 351.3,
pitch: -73,
},
showSun: false,
showMoon: false,
showSkyBox: false,
showSkyAtmosphere: false,
fog: false,
sceneMode: 1,
backgroundColor: "rgba(0,0,0,0)",
backgroundImage: `url(${require("../assets/images/big_bg.png")})`,
orderIndependentTranslucency: false,
contextOptions: { webgl: { antialias: mars3d.Util.isPCBroswer() } },
globe: {
show: false, //
showGroundAtmosphere: false,
enableLighting: false,
},
},
control: {
// contextmenu: { preventDefault: false, hasDefault: false },
},
basemaps: [
{
name: "mapbox影像图",
icon: "img/basemaps/mapboxSatellite.png",
type: "mapbox",
username: "sharealex",
styleId: "cly5i21fn00e901prgq643t4r",
token:
"pk.eyJ1Ijoic2hhcmVhbGV4IiwiYSI6ImNsaXNhZmRjbTFhbnczZmxib3h1OW05YXYifQ.PhlKv60ar3K359d8x2yBPw",
tilesize: 256,
scaleFactor: false,
show: false,
},
],
},
map: null,
mapLayer: {},
chinaUrl: basePathUrl + "lib/geoJson/json/china.json",
};
},
methods: {
mapLoad(map) {
this.map = map;
map.setSceneOptions({
cameraController: {
// enableZoom: false,
// enableTranslate: false,
// enableRotate: false,
// enableTilt: false,
},
});
this.mapLayer.china = new mars3d.layer.GraphicLayer({
zIndex: 10,
});
map.addLayer(this.mapLayer.china);
//
this.initChina();
},
initChina() {
mars3d.Util.fetchJson({ url: this.chinaUrl }).then((res) => {
const arr = mars3d.Util.geoJsonToGraphics(res);
arr.map((item, index) => {
this.cityAttr[item.attr.name] = item.attr;
const polygonEntity = new mars3d.graphic.PolygonEntity({
positions: item.positions,
style: {
fill: true,
lastMaterialType: "Image",
materialOptions: {
materialType: "Image",
image: require("../assets/images/map-bg.jpg"),
opacity: 1,
repeat_x: 1,
repeat_y: 1,
transparent: false,
},
materialType: "Image",
opacity: 1,
outline: true,
outlineWidth: 1.5,
outlineColor: "#00BEFF",
setHeight: 1000000,
},
});
const wall = new mars3d.graphic.WallPrimitive({
positions: item.positions,
style: {
setHeight: -20000,
diffHeight: 1000000, //
width: 15,
materialType: mars3d.MaterialType.Image2,
materialOptions: {
image: require("../assets/images/fence-top.png"),
color: "#0064F8",
},
},
});
this.mapLayer.china.addGraphic(polygonEntity);
this.mapLayer.china.addGraphic(wall);
});
this.createEchartsLayer();
});
},
async createEchartsLayer() {
const options = await this.getEchartsOption();
const echartsLayer = new mars3d.layer.EchartsLayer(options);
this.map.addLayer(echartsLayer);
//
window.addEventListener("resize", function () {
echartsLayer.resize();
});
},
async getEchartsOption() {
let res = await getProvince();
this.total = res.data.length;
const items = res.data.map((item, index) => {
if (index == 0) {
item = {
level: 1,
name: item.city,
label: item.city,
value: this.cityAttr[item.city].center,
symbol: "",
symbolSize: [65, 65],
};
} else {
item = {
level: 2,
symbol: "",
name: item.city,
label: item.city,
category: 0,
active: true,
speed: 6,
value: this.cityAttr[item.city].center,
belong: res.data[0].city,
symbolSize: [40, 40],
};
}
return item;
});
// const items = [
// {
// level: 1,
// name: "",
// label: "jiangsu",
// value: [118.767413, 32.041544],
// symbol: "",
// symbolSize: [30, 30],
// },
// {
// level: 2,
// symbol: "",
// name: "",
// label: "anhui",
// category: 0,
// active: true,
// speed: 6,
// value: [117.283042, 31.86119],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [120.153576, 30.287459],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [102.712251, 25.040609],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [101.778916, 36.623178],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [111.670801, 40.818311],
// belong: "",
// },
// ];
const lineColor = ["#fff", "#7BF7AD", "#00fcff"];
//
const symbolList = ["image://" + point1, "image://" + point2];
// 线
const pointSymbol = ["image://" + linePoint1, "image://" + linePoint2];
// level = 1
items.forEach((el) => {
el.symbol = symbolList[el.level - 1];
});
const dataArr = [[], [], []];
items.forEach((el) => {
if (el.belong) {
items.forEach((element) => {
if (el.belong === element.name) {
console.log(dataArr[el.level - 1]);
dataArr[el.level - 1].push([
{
coord: element.value,
},
{
coord: el.value,
},
]);
}
});
}
});
const seriesOne = [
{
type: "effectScatter",
layout: "none",
showEffectOn: "emphasis",
// coordinateSystem: "cartesian2d",
coordinateSystem: "mars3dMap",
symbolSize: [20, 20],
symbolOffset: [0, -10],
zlevel: 3,
circular: {
rotateLabel: true,
},
label: {
normal: {
show: true,
position: "bottom",
formatter: function (e) {
return e.data.level == 1 ? "" : e.name;
},
fontSize: 12,
color: "#fff",
textBorderColor: "#2aa4e8",
offset: [0, 0],
},
},
itemStyle: {
normal: {
shadowColor: "none",
},
},
data: items,
},
];
//线
const lineSeries = [];
dataArr.forEach((el, index) => {
lineSeries.push({
name: "",
type: "lines",
// coordinateSystem: "cartesian2d",
coordinateSystem: "mars3dMap",
zlevel: 1,
effect: {
show: true,
smooth: false,
trailLength: 0,
symbol: pointSymbol[index],
symbolSize: [10, 30],
period: 4,
},
lineStyle: {
width: 2,
color: lineColor[index],
curveness: -0.2,
},
data: el,
});
});
const seriesData = seriesOne.concat(lineSeries);
const option = {
animation: false,
// backgroundColor: '#000',
fixedHeight: 900009,
series: seriesData,
};
return option;
},
},
components: {
MarsMap,
},
};
</script>
<style lang="scss" scoped>
.extend-box {
position: absolute;
left: 50%;
top: 103px;
z-index: 60;
transform: translateX(-50%);
display: flex;
flex-direction: column;
align-items: center;
.sub-title {
width: 200px;
height: 38px;
background: url("../assets/images/extend.png");
background-size: 100% 100%;
margin-bottom: 8px;
}
.data-total {
font-size: 40px;
color: #ffffff;
letter-spacing: 1px;
text-align: center;
font-weight: bold;
background-image: linear-gradient(0deg, #00e5ff 0%, #d8d8d8 100%);
-webkit-background-clip: text; /* 使用-webkit-前缀兼容WebKit内核浏览器 */
background-clip: text;
color: transparent;
}
}
</style>

@ -2,37 +2,54 @@
<div class="map-container">
<div class="extend-box">
<div class="sub-title"></div>
<div class="data-total">5</div>
<div class="data-total">{{ total }}</div>
</div>
<mars-map @mapLoad="mapLoad" :options="options"></mars-map>
<div class="island"></div>
</div>
</template>
<script>
import point1 from "@/assets/images/levelcity.png";
import point2 from "@/assets/images/symbol2.png";
import point2 from "@/assets/images/province.png";
import linePoint1 from "@/assets/images/linePoint1.png";
import linePoint2 from "@/assets/images/linePoint2.png";
import MarsMap from "@/components/mars-map";
// import province from "@/assets/images/province.png";
import { getProvince } from "@/api/yunkun/index.js";
export default {
data() {
const basePathUrl = window.basePathUrl || "";
return {
cityAttr: {},
total: 0,
options: {
scene: {
center: {
lat: 2.849636,
lng: 109.828071,
alt: 12509129.9,
heading: 353.3,
pitch: -73.4,
lat: -9.65789,
lng: 110.718514,
alt: 13807610.5,
heading: 351.3,
pitch: -73,
},
showSun: false,
showMoon: false,
showSkyBox: false,
showSkyAtmosphere: false,
fog: false,
sceneMode: 1,
backgroundColor: "rgba(0,0,0,0)",
backgroundImage: `url(${require("../assets/images/big_bg.png")})`,
orderIndependentTranslucency: false,
contextOptions: { webgl: { antialias: mars3d.Util.isPCBroswer() } },
globe: {
show: false, //
showGroundAtmosphere: false,
enableLighting: false,
},
},
control: {
contextmenu: { preventDefault: false, hasDefault: false },
// contextmenu: { preventDefault: false, hasDefault: false },
},
basemaps: [
{
@ -45,7 +62,7 @@ export default {
"pk.eyJ1Ijoic2hhcmVhbGV4IiwiYSI6ImNsaXNhZmRjbTFhbnczZmxib3h1OW05YXYifQ.PhlKv60ar3K359d8x2yBPw",
tilesize: 256,
scaleFactor: false,
show: true,
show: false,
},
],
},
@ -59,15 +76,11 @@ export default {
this.map = map;
map.setSceneOptions({
showSkyBox: false,
showSkyAtmosphere: false,
sceneMode: 1,
cameraController: {
enableZoom: false,
enableTranslate: false,
enableRotate: false,
enableTilt: false,
// enableZoom: false,
// enableTranslate: false,
// enableRotate: false,
// enableTilt: false,
},
});
@ -106,19 +119,19 @@ export default {
outline: true,
outlineWidth: 1.5,
outlineColor: "#00BEFF",
setHeight: 900009,
setHeight: 1000000,
},
});
const wall = new mars3d.graphic.WallPrimitive({
positions: item.positions,
style: {
setHeight: -20000,
diffHeight: 900000, //
width: 10,
diffHeight: 1000000, //
width: 15,
materialType: mars3d.MaterialType.Image2,
materialOptions: {
image: require("../assets/images/fence-top.png"),
color: "#0071F8",
color: "#0064F8",
},
},
});
@ -141,99 +154,72 @@ export default {
},
async getEchartsOption() {
let res = await getProvince();
// let res = await getProvince();
const items = res.data.map((item, index) => {
if (index == 0) {
item = {
level: 1,
name: item.city,
label: item.city,
value: this.cityAttr[item.city].center,
symbol: "",
symbolSize: [65, 65],
};
} else {
item = {
level: 2,
symbol: "",
name: item.city,
label: item.city,
category: 0,
active: true,
speed: 6,
value: this.cityAttr[item.city].center,
belong: res.data[0].city,
symbolSize: [40, 40],
};
}
return item;
});
// const items = [
// {
// level: 1,
// name: "",
// label: "jiangsu",
// value: [118.767413, 32.041544],
// symbol: "",
// symbolSize: [30, 30],
// },
// {
// level: 2,
// symbol: "",
// name: "",
// label: "anhui",
// category: 0,
// active: true,
// speed: 6,
// value: [117.283042, 31.86119],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [120.153576, 30.287459],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [102.712251, 25.040609],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [101.778916, 36.623178],
// belong: "",
// },
// {
// level: 2,
// symbol: "",
// name: "",
// category: 0,
// active: true,
// speed: 6,
// value: [111.670801, 40.818311],
// belong: "",
// },
// ];
const items = [
{
level: 1,
name: "北京",
label: "beijing",
value: [116.407395, 39.904211],
symbol: "",
symbolSize: [84, 80],
},
{
level: 2,
symbol: "",
name: "沈阳",
label: "langfang",
category: 0,
active: true,
speed: 6,
value: [122.904763, 41.689105],
belong: "北京",
},
{
level: 2,
symbol: "",
name: "西宁",
category: 0,
active: true,
speed: 6,
value: [101.4038, 36.8207],
belong: "北京",
},
{
level: 2,
symbol: "",
name: "兰州",
category: 0,
active: true,
speed: 6,
value: [103.5901, 36.3043],
belong: "北京",
},
{
level: 2,
symbol: "",
name: "杭州",
category: 0,
active: true,
speed: 6,
value: [119.5313, 29.8773],
belong: "北京",
},
{
level: 2,
symbol: "",
name: "四川",
category: 0,
active: true,
speed: 6,
value: [103.9526, 30.7617],
belong: "北京",
},
];
this.total = items.length;
const lineColor = ["#fff", "#f6fb05", "#00fcff"];
const lineColor = ["#7BF7AD", "#7BF7AD", "##7BF7AD"];
//
const symbolList = ["image://" + point1, "image://" + point2];
@ -251,7 +237,6 @@ export default {
if (el.belong) {
items.forEach((element) => {
if (el.belong === element.name) {
console.log(dataArr[el.level - 1]);
dataArr[el.level - 1].push([
{
coord: element.value,
@ -272,24 +257,21 @@ export default {
showEffectOn: "emphasis",
// coordinateSystem: "cartesian2d",
coordinateSystem: "mars3dMap",
symbolSize: [20, 20],
symbolSize: [40, 60],
symbolOffset: [0, -10],
zlevel: 3,
circular: {
rotateLabel: true,
},
label: {
normal: {
show: true,
position: "bottom",
formatter: function (e) {
return e.data.level == 1 ? "" : e.name;
},
fontSize: 12,
formatter: "{b}",
fontSize: 14,
color: "#fff",
textBorderColor: "#2aa4e8",
offset: [0, 0],
offset: [0, -5],
},
},
itemStyle: {
@ -300,7 +282,6 @@ export default {
data: items,
},
];
//线
const lineSeries = [];
dataArr.forEach((el, index) => {
lineSeries.push({
@ -319,7 +300,7 @@ export default {
},
lineStyle: {
width: 2,
width: 3,
color: lineColor[index],
curveness: -0.2,
},
@ -332,7 +313,7 @@ export default {
const option = {
animation: false,
// backgroundColor: '#000',
fixedHeight: 900009,
fixedHeight: 1000009,
series: seriesData,
};
return option;
@ -348,7 +329,7 @@ export default {
.extend-box {
position: absolute;
left: 50%;
top: 100px;
top: 103px;
z-index: 60;
transform: translateX(-50%);
display: flex;
@ -373,4 +354,14 @@ export default {
color: transparent;
}
}
.island {
position: absolute;
right: 544px;
bottom: calc(34px + 9px);
z-index: 60;
width: 160px;
height: 200px;
background: url("../assets/images/island.png");
background-size: 100% 100%;
}
</style>

Loading…
Cancel
Save