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
864c1424
Commit
864c1424
authored
Nov 19, 2025
by
xinzhedeai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: car切换到person ,显示问题
parent
9d95ac5a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
51 deletions
+89
-51
index.vue
src/views/index.vue
+89
-51
No files found.
src/views/index.vue
View file @
864c1424
...
...
@@ -553,59 +553,97 @@ export default {
console
.
error
(
"
定位到模型上方失败:
"
,
error
);
}
},
// 修改createPersonModel方法
createPersonModel
()
{
if
(
!
this
.
personModelInterval
)
{
this
.
personModelInterval
=
setInterval
(()
=>
{
console
.
log
(
"
开始获取实时数据
"
);
// 只清除当前类型的实体
this
.
clearEntities
();
// if (this.bgEntities) {
// for (let key in this.bgEntities) {
// if (isNaN(parseFloat(key))) {
// // 非数字键名的是人员实体
// this.viewer.entities.remove(this.bgEntities[key]);
// delete this.bgEntities[key];
// }
// }
// }
// 从API获取最新的人员定位数据
this
.
personCardList
((
list
)
=>
{
console
.
log
(
"
人员数据
"
,
this
.
personnelList
);
// 创建新实体
for
(
let
item
of
this
.
personnelList
)
{
let
lng
=
Number
(
item
.
lng
);
let
lat
=
Number
(
item
.
lat
);
let
height
=
Number
(
item
.
height
);
let
position
=
Cesium
.
Cartesian3
.
fromDegrees
(
lng
,
lat
,
height
);
console
.
log
(
item
.
perName
,
position
);
// 创建人员标记
let
entity
=
this
.
viewer
.
entities
.
add
({
position
:
position
,
label
:
{
text
:
item
.
perName
,
font
:
"
16px
"
,
backgroundColor
:
Cesium
.
Color
.
fromCssColorString
(
"
#173349
"
),
showBackground
:
true
,
fillColor
:
Cesium
.
Color
.
YELLOW
,
depthTestAgainstTerrain
:
false
,
// 禁用地形深度测试
pixelOffset
:
new
Cesium
.
Cartesian2
(
0
,
-
35
),
},
billboard
:
{
image
:
"
/poi-marker-default.png
"
,
scale
:
0.5
,
heightReference
:
Cesium
.
HeightReference
.
CLAMP_TO_3D_TILE
,
},
description
:
`<div><h4>
${
item
.
perName
}${
item
.
status
}
</h4></div>`
,
fixedFrame
:
Cesium
.
Transforms
.
eastNorthUpToFixedFrame
(
position
),
});
entity
.
info
=
item
;
// 添加 info 属性
entity
.
type
=
"
person
"
;
// 添加类型标记
this
.
bgEntities
[
item
.
perName
]
=
entity
;
// 存储新实体
}
});
},
1000
);
// 每10秒刷新一次
// 先清除可能存在的定时器,避免重复执行
if
(
this
.
personModelInterval
)
{
clearInterval
(
this
.
personModelInterval
);
this
.
personModelInterval
=
null
;
}
// 立即生成并显示人员实体,而不是等待定时器执行
console
.
log
(
"
立即创建人员实体
"
);
// 清除现有实体
this
.
clearEntities
();
// 立即调用personCardList生成数据并创建实体
this
.
personCardList
((
list
)
=>
{
console
.
log
(
"
人员数据
"
,
this
.
personnelList
);
// 创建新实体
for
(
let
item
of
this
.
personnelList
)
{
let
lng
=
Number
(
item
.
lng
);
let
lat
=
Number
(
item
.
lat
);
let
height
=
Number
(
item
.
height
);
let
position
=
Cesium
.
Cartesian3
.
fromDegrees
(
lng
,
lat
,
height
);
console
.
log
(
item
.
perName
,
position
);
// 创建人员标记
let
entity
=
this
.
viewer
.
entities
.
add
({
position
:
position
,
label
:
{
text
:
item
.
perName
,
font
:
"
16px
"
,
backgroundColor
:
Cesium
.
Color
.
fromCssColorString
(
"
#173349
"
),
showBackground
:
true
,
fillColor
:
Cesium
.
Color
.
YELLOW
,
depthTestAgainstTerrain
:
false
,
pixelOffset
:
new
Cesium
.
Cartesian2
(
0
,
-
35
),
},
billboard
:
{
image
:
"
/poi-marker-default.png
"
,
scale
:
0.5
,
heightReference
:
Cesium
.
HeightReference
.
CLAMP_TO_3D_TILE
,
},
description
:
`<div><h4>
${
item
.
perName
}${
item
.
status
}
</h4></div>`
,
fixedFrame
:
Cesium
.
Transforms
.
eastNorthUpToFixedFrame
(
position
),
});
entity
.
info
=
item
;
// 添加 info 属性
entity
.
type
=
"
person
"
;
// 添加类型标记
this
.
bgEntities
[
item
.
perName
]
=
entity
;
// 存储新实体
}
});
// 设置定时刷新,改为10秒(10000ms)
this
.
personModelInterval
=
setInterval
(()
=>
{
console
.
log
(
"
开始获取实时数据
"
);
// 清除现有实体
this
.
clearEntities
();
// 从API获取最新的人员定位数据
this
.
personCardList
((
list
)
=>
{
console
.
log
(
"
人员数据
"
,
this
.
personnelList
);
// 创建新实体
for
(
let
item
of
this
.
personnelList
)
{
let
lng
=
Number
(
item
.
lng
);
let
lat
=
Number
(
item
.
lat
);
let
height
=
Number
(
item
.
height
);
let
position
=
Cesium
.
Cartesian3
.
fromDegrees
(
lng
,
lat
,
height
);
console
.
log
(
item
.
perName
,
position
);
// 创建人员标记
let
entity
=
this
.
viewer
.
entities
.
add
({
position
:
position
,
label
:
{
text
:
item
.
perName
,
font
:
"
16px
"
,
backgroundColor
:
Cesium
.
Color
.
fromCssColorString
(
"
#173349
"
),
showBackground
:
true
,
fillColor
:
Cesium
.
Color
.
YELLOW
,
depthTestAgainstTerrain
:
false
,
pixelOffset
:
new
Cesium
.
Cartesian2
(
0
,
-
35
),
},
billboard
:
{
image
:
"
/poi-marker-default.png
"
,
scale
:
0.5
,
heightReference
:
Cesium
.
HeightReference
.
CLAMP_TO_3D_TILE
,
},
description
:
`<div><h4>
${
item
.
perName
}${
item
.
status
}
</h4></div>`
,
fixedFrame
:
Cesium
.
Transforms
.
eastNorthUpToFixedFrame
(
position
),
});
entity
.
info
=
item
;
// 添加 info 属性
entity
.
type
=
"
person
"
;
// 添加类型标记
this
.
bgEntities
[
item
.
perName
]
=
entity
;
// 存储新实体
}
});
},
10000
);
// 改为10秒刷新一次,与注释一致
},
personCardList
(
fn
)
{
...
...
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