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
48dd392a
Commit
48dd392a
authored
Nov 18, 2025
by
xinzhedeai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add:添加cesium 人员 label提示弹窗
parent
1714e996
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
index.vue
src/views/index.vue
+63
-0
No files found.
src/views/index.vue
View file @
48dd392a
...
...
@@ -294,11 +294,16 @@ export default {
// 监听窗口大小变化
window
.
addEventListener
(
"
resize
"
,
this
.
handleResize
);
},
// 在beforeDestroy方法中添加清理代码
beforeDestroy
()
{
window
.
removeEventListener
(
"
resize
"
,
this
.
handleResize
);
if
(
this
.
viewer
)
{
this
.
viewer
.
destroy
();
}
// 清理点击事件处理器
if
(
this
.
clickHandler
)
{
this
.
clickHandler
.
destroy
();
}
// 组件销毁前清理地图资源
if
(
this
.
viewer
)
{
this
.
viewer
.
destroy
();
...
...
@@ -665,6 +670,8 @@ export default {
if
(
tileset
)
{
this
.
tileset
=
tileset
;
this
.
locateToTileset
();
// 添加鼠标点击事件监听器,用于控制人员信息label显示
this
.
addEntityClickHandler
();
}
}
catch
(
error
)
{
console
.
error
(
`加载倾斜摄影模型失败:
${
error
}
`
);
...
...
@@ -675,6 +682,62 @@ export default {
console
.
error
(
"
Cesium地图初始化失败:
"
,
error
);
}
},
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
);
},
/**
* 获取倾斜摄影模型的经纬度并将摄像机视角转向模型上方
*/
...
...
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