Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cesium-frame
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
jlc
cesium-frame
Commits
e5dafbfa
Commit
e5dafbfa
authored
Aug 06, 2024
by
jlc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update:指定连接类型添加虚线连接
parent
b032a3d1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
5 deletions
+66
-5
specifyConnectionType-function.js
...e/specifyConnectionType/specifyConnectionType-function.js
+52
-2
specifyConnectionType.vue
...s/visible/specifyConnectionType/specifyConnectionType.vue
+14
-3
No files found.
src/examples/visible/specifyConnectionType/specifyConnectionType-function.js
View file @
e5dafbfa
...
...
@@ -92,7 +92,7 @@ export class SpecifyConnectionType {
}
// 连接方式为静态线
useStatic
()
{
useStatic
Lines
()
{
// 创建连线函数
function
createConnection
(
viewer
,
satellitePositionProperty
,
stationPosition
,
color
,
maxDistance
)
{
return
viewer
.
entities
.
add
({
...
...
@@ -137,7 +137,57 @@ export class SpecifyConnectionType {
});
this
.
connections
=
[];
}
else
{
this
.
useStatic
();
this
.
useStaticLines
();
}
this
.
visible
=
!
this
.
visible
;
}
// 连接方式为虚线
useDashedLine
()
{
// 创建连线函数
function
createConnection
(
viewer
,
satellitePositionProperty
,
stationPosition
,
color
,
maxDistance
)
{
return
viewer
.
entities
.
add
({
polyline
:
{
positions
:
new
Cesium
.
CallbackProperty
((
time
)
=>
{
const
satellitePosition
=
satellitePositionProperty
.
getValue
(
time
);
const
distance
=
Cesium
.
Cartesian3
.
distance
(
satellitePosition
,
stationPosition
);
if
(
distance
>
maxDistance
)
{
return
[];
// 返回空数组隐藏连线
}
return
[
satellitePosition
,
stationPosition
];
},
false
),
width
:
1.5
,
material
:
new
Cesium
.
PolylineDashMaterialProperty
({
color
:
color
,
dashLength
:
16
})
}
});
}
// 获取测站位置
const
stationOnePosition
=
Cesium
.
Cartesian3
.
fromDegrees
(...
this
.
stationOne
.
position
);
const
stationTwoPosition
=
Cesium
.
Cartesian3
.
fromDegrees
(...
this
.
stationTwo
.
position
);
const
stationThreePosition
=
Cesium
.
Cartesian3
.
fromDegrees
(...
this
.
stationThree
.
position
);
// 最大连接显示距离
const
maxDistance
=
5000000
;
// 创建连线
this
.
connections
.
push
(
createConnection
(
this
.
viewer
,
this
.
satelliteEntity
.
position
,
stationOnePosition
,
Cesium
.
Color
.
BLUE
,
maxDistance
));
this
.
connections
.
push
(
createConnection
(
this
.
viewer
,
this
.
satelliteEntity
.
position
,
stationTwoPosition
,
Cesium
.
Color
.
GREEN
,
maxDistance
));
this
.
connections
.
push
(
createConnection
(
this
.
viewer
,
this
.
satelliteEntity
.
position
,
stationThreePosition
,
Cesium
.
Color
.
YELLOW
,
maxDistance
));
}
// 切换虚线的显示和隐藏
toggleDashedLine
()
{
if
(
this
.
visible
)
{
this
.
connections
.
forEach
(
connection
=>
{
this
.
viewer
.
entities
.
remove
(
connection
);
});
this
.
connections
=
[];
}
else
{
this
.
useDashedLine
();
}
this
.
visible
=
!
this
.
visible
;
}
...
...
src/examples/visible/specifyConnectionType/specifyConnectionType.vue
View file @
e5dafbfa
<
template
>
<div
id=
"cesiumContainer"
class=
"cesium-container"
></div>
<div>
<button
class=
"btn-class"
@
click=
"createConnections"
>
静态线
</button>
<div
class=
"btn-class"
>
<button>
多个起点的脉冲线
</button>
<button>
圆锥
</button>
<button>
脉冲圆锥
</button>
<button>
一个脉冲的线
</button>
<button
@
click=
"StaticLines"
>
静态线
</button>
<button
@
click=
"DashedLine"
>
虚线
</button>
</div>
</
template
>
...
...
@@ -93,9 +98,15 @@ onMounted(() => {
document
.
head
.
appendChild
(
link
);
});
function
createConnections
()
{
// 连接方式为静态线类方法的调用
function
StaticLines
()
{
satellite
.
toggleStaticLines
();
}
// 连接方式为虚线类方法的调用
function
DashedLine
()
{
satellite
.
toggleDashedLine
();
}
</
script
>
<
style
>
...
...
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