Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JINRUN-DP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xinzhedeai
JINRUN-DP
Commits
917b2495
Commit
917b2495
authored
Nov 19, 2025
by
xinzhedeai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add:better
parent
864c1424
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
75 deletions
+21
-75
index.vue
src/views/index.vue
+21
-75
No files found.
src/views/index.vue
View file @
917b2495
...
@@ -280,17 +280,8 @@ export default {
...
@@ -280,17 +280,8 @@ export default {
],
],
// 新增:车辆数据
// 新增:车辆数据
vehicleList
:
[],
vehicleList
:
[],
personModelInterval
:
null
,
intervaler
:
null
,
bgEntities
:
{},
// 所有的key都对应一个实体对象。而人员的实体对应的key不是数字。
bgEntities
:
{},
// 所有的key都对应一个实体对象。而人员的实体对应的key不是数字。
// 轨迹追踪相关数据
selectedPerson
:
""
,
// 选中的人员
timePoints
:
[],
// 时间点数组
currentTimeIndex
:
0
,
// 当前时间索引
personTrajectories
:
{},
// 人员轨迹数据 { 人员名称: [{time, lng, lat, height}] }
trailEntities
:
{},
// 轨迹实体
isTracking
:
false
,
// 是否正在实时追踪
currentTimeDisplay
:
""
,
// 当前显示时间
};
};
},
},
mounted
()
{
mounted
()
{
...
@@ -307,25 +298,35 @@ export default {
...
@@ -307,25 +298,35 @@ export default {
},
},
// 在beforeDestroy方法中添加清理代码
// 在beforeDestroy方法中添加清理代码
beforeDestroy
()
{
beforeDestroy
()
{
// 清理事件监听
window
.
removeEventListener
(
"
resize
"
,
this
.
handleResize
);
window
.
removeEventListener
(
"
resize
"
,
this
.
handleResize
);
// 清理地图资源
if
(
this
.
viewer
)
{
if
(
this
.
viewer
)
{
this
.
viewer
.
destroy
();
this
.
viewer
.
destroy
();
this
.
viewer
=
null
;
}
}
// 清理点击事件处理器
// 清理点击事件处理器
if
(
this
.
clickHandler
)
{
if
(
this
.
clickHandler
)
{
this
.
clickHandler
.
destroy
();
this
.
clickHandler
.
destroy
();
this
.
clickHandler
=
null
;
}
}
// 组件销毁前清理地图资源
// 组件销毁前清理地图资源
if
(
this
.
viewer
)
{
if
(
this
.
viewer
)
{
this
.
viewer
.
destroy
();
this
.
viewer
.
destroy
();
this
.
viewer
=
null
;
this
.
viewer
=
null
;
}
}
if
(
this
.
personModelInterval
)
{
// 清理定时器
clearInterval
(
this
.
personModelInterval
);
if
(
this
.
intervaler
)
{
clearInterval
(
this
.
intervaler
);
}
}
if
(
this
.
trackingInterval
)
{
if
(
this
.
trackingInterval
)
{
clearInterval
(
this
.
trackingInterval
);
clearInterval
(
this
.
trackingInterval
);
}
}
// 清空实体引用
this
.
bgEntities
=
{};
this
.
trailEntities
=
{};
},
},
methods
:
{
methods
:
{
// 新增:实体类型选择变化处理
// 新增:实体类型选择变化处理
...
@@ -426,61 +427,6 @@ export default {
...
@@ -426,61 +427,6 @@ export default {
}
}
},
},
addEntityClickHandler
()
{
// 创建鼠标事件处理器
this
.
clickHandler
=
new
Cesium
.
ScreenSpaceEventHandler
(
this
.
viewer
.
canvas
);
// 监听鼠标左键点击事件
this
.
clickHandler
.
setInputAction
((
click
)
=>
{
// 检测点击位置的实体
const
pickedObject
=
this
.
viewer
.
scene
.
pick
(
click
.
position
);
// 修复条件判断:检查是否是人员实体,通过判断是否有info属性或是否存在于bgEntities中
if
(
Cesium
.
defined
(
pickedObject
)
&&
pickedObject
.
id
&&
pickedObject
.
id
.
info
// 直接检查实体是否有info属性
)
{
// 获取点击的实体
const
entity
=
pickedObject
.
id
;
const
personInfo
=
entity
.
info
;
// 如果已有详细信息label,则移除它
if
(
entity
.
detailLabel
)
{
this
.
viewer
.
entities
.
remove
(
entity
.
detailLabel
);
delete
entity
.
detailLabel
;
return
;
}
console
.
log
(
"
点击实体了
"
,
personInfo
);
// 创建详细信息label
const
detailLabel
=
this
.
viewer
.
entities
.
add
({
position
:
entity
.
position
.
getValue
(),
label
:
{
text
:
`
${
personInfo
.
perName
}
\n状态:
${
personInfo
.
status
===
"
online
"
?
"
在线
"
:
"
离线
"
}
\n高度:
${
personInfo
.
height
.
toFixed
(
2
)}
m`
,
font
:
"
14px 微软雅黑
"
,
backgroundColor
:
Cesium
.
Color
.
fromCssColorString
(
"
#173349
"
),
showBackground
:
true
,
fillColor
:
Cesium
.
Color
.
WHITE
,
pixelOffset
:
new
Cesium
.
Cartesian2
(
0
,
-
60
),
eyeOffset
:
new
Cesium
.
Cartesian3
(
0
,
0
,
-
10
),
horizontalOrigin
:
Cesium
.
HorizontalOrigin
.
CENTER
,
verticalOrigin
:
Cesium
.
VerticalOrigin
.
TOP
,
scaleByDistance
:
new
Cesium
.
NearFarScalar
(
1000
,
1
,
500000
,
0.5
),
disableDepthTestDistance
:
Number
.
POSITIVE_INFINITY
,
// 确保始终显示在最前面
},
});
// 将详细信息label关联到实体,便于后续管理
entity
.
detailLabel
=
detailLabel
;
}
},
Cesium
.
ScreenSpaceEventType
.
LEFT_CLICK
);
},
/**
/**
* 获取倾斜摄影模型的经纬度并将摄像机视角转向模型上方
* 获取倾斜摄影模型的经纬度并将摄像机视角转向模型上方
*/
*/
...
@@ -556,9 +502,9 @@ export default {
...
@@ -556,9 +502,9 @@ export default {
// 修改createPersonModel方法
// 修改createPersonModel方法
createPersonModel
()
{
createPersonModel
()
{
// 先清除可能存在的定时器,避免重复执行
// 先清除可能存在的定时器,避免重复执行
if
(
this
.
personModelInterval
)
{
if
(
this
.
intervaler
)
{
clearInterval
(
this
.
personModelInterval
);
clearInterval
(
this
.
intervaler
);
this
.
personModelInterval
=
null
;
this
.
intervaler
=
null
;
}
}
// 立即生成并显示人员实体,而不是等待定时器执行
// 立即生成并显示人员实体,而不是等待定时器执行
...
@@ -603,7 +549,7 @@ export default {
...
@@ -603,7 +549,7 @@ export default {
});
});
// 设置定时刷新,改为10秒(10000ms)
// 设置定时刷新,改为10秒(10000ms)
this
.
personModelInterval
=
setInterval
(()
=>
{
this
.
intervaler
=
setInterval
(()
=>
{
console
.
log
(
"
开始获取实时数据
"
);
console
.
log
(
"
开始获取实时数据
"
);
// 清除现有实体
// 清除现有实体
this
.
clearEntities
();
this
.
clearEntities
();
...
@@ -690,9 +636,9 @@ export default {
...
@@ -690,9 +636,9 @@ export default {
// 新增:车辆模型创建方法
// 新增:车辆模型创建方法
createVehicleModel
()
{
createVehicleModel
()
{
// 清除定时器,避免重复执行
// 清除定时器,避免重复执行
if
(
this
.
personModelInterval
)
{
if
(
this
.
intervaler
)
{
clearInterval
(
this
.
personModelInterval
);
clearInterval
(
this
.
intervaler
);
this
.
personModelInterval
=
null
;
this
.
intervaler
=
null
;
}
}
// 清除现有实体
// 清除现有实体
...
@@ -734,7 +680,7 @@ export default {
...
@@ -734,7 +680,7 @@ export default {
}
}
// 设置定时刷新
// 设置定时刷新
this
.
personModelInterval
=
setInterval
(()
=>
{
this
.
intervaler
=
setInterval
(()
=>
{
console
.
log
(
"
开始获取实时车辆数据
"
);
console
.
log
(
"
开始获取实时车辆数据
"
);
this
.
generateVehicleData
();
this
.
generateVehicleData
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment