|
|
@ -7,18 +7,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
<script setup>
|
|
|
|
import AMapLoader from '@amap/amap-jsapi-loader';
|
|
|
|
import AMapLoader from '@amap/amap-jsapi-loader';
|
|
|
|
|
|
|
|
import {getCarGpsList, listBasetyre} from '@/api/realTimeMonitoring/vehicleMonitoring'
|
|
|
|
|
|
|
|
|
|
|
|
const treeData = [
|
|
|
|
const treeData = ref([
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level one 1',
|
|
|
|
title: 'Level one 1',
|
|
|
|
id: 1,
|
|
|
|
id: 1,
|
|
|
|
children: [
|
|
|
|
baseCarList: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level two 1-1',
|
|
|
|
title: 'Level two 1-1',
|
|
|
|
id: 11,
|
|
|
|
id: 11,
|
|
|
|
children: [
|
|
|
|
baseCarList: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level three 1-1-1',
|
|
|
|
title: 'Level three 1-1-1',
|
|
|
|
id: 111,
|
|
|
|
id: 111,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
@ -26,52 +27,49 @@ const treeData = [
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level one 2',
|
|
|
|
title: 'Level one 2',
|
|
|
|
children: [
|
|
|
|
baseCarList: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level two 2-1',
|
|
|
|
title: 'Level two 2-1',
|
|
|
|
children: [
|
|
|
|
baseCarList: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level three 2-1-1',
|
|
|
|
title: 'Level three 2-1-1',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level two 2-2',
|
|
|
|
title: 'Level two 2-2',
|
|
|
|
children: [
|
|
|
|
baseCarList: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level three 2-2-1',
|
|
|
|
title: 'Level three 2-2-1',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level one 3',
|
|
|
|
title: 'Level one 3',
|
|
|
|
children: [
|
|
|
|
baseCarList: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level two 3-1',
|
|
|
|
title: 'Level two 3-1',
|
|
|
|
children: [
|
|
|
|
baseCarList: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level three 3-1-1',
|
|
|
|
title: 'Level three 3-1-1',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level two 3-2',
|
|
|
|
title: 'Level two 3-2',
|
|
|
|
children: [
|
|
|
|
baseCarList: [
|
|
|
|
{
|
|
|
|
{
|
|
|
|
label: 'Level three 3-2-1',
|
|
|
|
title: 'Level three 3-2-1',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
])
|
|
|
|
const treeDefaultProps = {
|
|
|
|
const treeDefaultProps = {label: 'title', children: 'baseCarList'}
|
|
|
|
children: 'children',
|
|
|
|
|
|
|
|
label: 'label',
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const treeClick = (data) => {
|
|
|
|
const treeClick = (data) => {
|
|
|
|
console.log(data)
|
|
|
|
console.log(data)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -109,18 +107,19 @@ const mockRequest = () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const setMarker = async () => {
|
|
|
|
const setMarker = async () => {
|
|
|
|
const markerArr = await mockRequest()
|
|
|
|
const {data: markerArr} = await getCarGpsList()
|
|
|
|
|
|
|
|
console.log(markerArr)
|
|
|
|
markerArr.forEach(e => {
|
|
|
|
markerArr.forEach(e => {
|
|
|
|
|
|
|
|
|
|
|
|
// 点标记
|
|
|
|
// 点标记
|
|
|
|
let marker = new AMap.Marker({
|
|
|
|
let marker = new AMap.Marker({
|
|
|
|
content: '<div class="markerIcon" />',
|
|
|
|
content: '<div class="markerIcon" />',
|
|
|
|
position: e.location,
|
|
|
|
position: [e.longitude, e.latitude],
|
|
|
|
anchor: 'bottom-center',
|
|
|
|
anchor: 'bottom-center',
|
|
|
|
offset: new AMap.Pixel(0, 0),
|
|
|
|
offset: new AMap.Pixel(0, 0),
|
|
|
|
label: {
|
|
|
|
label: {
|
|
|
|
direction: 'top',
|
|
|
|
direction: 'top',
|
|
|
|
content: `<div class='info'>${e.title} - ${e.one}</div><div class='info'>${e.two} ${e.three}</div><div class='info'>${e.four}</div>`, //设置文本标注内容
|
|
|
|
content: `<div class='info'>${e.carLicense || ''} - ${e.state === 0? '在线':'离线'}</div><div class='info'>${e.two || ''} ${e.three || ''}</div><div class='info'>${e.four || ''}</div>`, //设置文本标注内容
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -129,9 +128,9 @@ const setMarker = async () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const setLine = async () => {
|
|
|
|
const setLine = async () => {
|
|
|
|
let path = [[116.478935, 39.997761], [103.85094, 35.987496], [106.205794, 38.458831], [108.983569, 34.285675], [111.761777, 40.875595]]
|
|
|
|
let path = [[116.478935, 39.997761], [103.85094, 35.987496], [106.205794, 38.458831], [108.983569, 34.285675], [111.761777, 40.875595]]
|
|
|
|
let polyline = new AMap.Polyline({
|
|
|
|
let polyline = new AMap.Polyline({
|
|
|
|
path:path,
|
|
|
|
path: path,
|
|
|
|
showDir: true,
|
|
|
|
showDir: true,
|
|
|
|
strokeColor: '#77DDFF', // 线颜色--浅蓝色
|
|
|
|
strokeColor: '#77DDFF', // 线颜色--浅蓝色
|
|
|
|
strokeWeight: 6, // 线宽
|
|
|
|
strokeWeight: 6, // 线宽
|
|
|
@ -139,7 +138,7 @@ const setLine = async () => {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
let distance = Math.round(AMap.GeometryUtil.distanceOfLine(path));
|
|
|
|
let distance = Math.round(AMap.GeometryUtil.distanceOfLine(path));
|
|
|
|
let text = new AMap.Text({
|
|
|
|
let text = new AMap.Text({
|
|
|
|
position: new AMap.LngLat(path[path.length-1][0],path[path.length-1][1]),
|
|
|
|
position: new AMap.LngLat(path[path.length - 1][0], path[path.length - 1][1]),
|
|
|
|
text: '路径长' + distance + '米',
|
|
|
|
text: '路径长' + distance + '米',
|
|
|
|
offset: new AMap.Pixel(0, 0)
|
|
|
|
offset: new AMap.Pixel(0, 0)
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -188,6 +187,13 @@ AMapLoader.load({
|
|
|
|
console.log(e);
|
|
|
|
console.log(e);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
listBasetyre().then(e => {
|
|
|
|
|
|
|
|
let res = JSON.stringify(e.rows)
|
|
|
|
|
|
|
|
let newObj = JSON.parse(res.replace(/"carLicense":/g,'"title":'))
|
|
|
|
|
|
|
|
treeData.value = newObj
|
|
|
|
|
|
|
|
console.log(newObj)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
<style>
|
|
|
|
<style>
|
|
|
|
.tree {
|
|
|
|
.tree {
|
|
|
@ -211,9 +217,10 @@ AMapLoader.load({
|
|
|
|
background-size: 100% 100%;
|
|
|
|
background-size: 100% 100%;
|
|
|
|
background-image: url("../../../assets/images/trucks.png");
|
|
|
|
background-image: url("../../../assets/images/trucks.png");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.amap-marker-label{
|
|
|
|
|
|
|
|
top:0 !important;
|
|
|
|
.amap-marker-label {
|
|
|
|
left:0 !important;
|
|
|
|
top: 0 !important;
|
|
|
|
transform: translate(calc(-50% + 32px),-100%);
|
|
|
|
left: 0 !important;
|
|
|
|
|
|
|
|
transform: translate(calc(-50% + 32px), -100%);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</style>
|