Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue-cesium-lyc
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
lyc
vue-cesium-lyc
Commits
8927f7fd
Commit
8927f7fd
authored
Aug 08, 2024
by
lyc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
0551d450
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
187 additions
and
57 deletions
+187
-57
App.vue
src/App.vue
+7
-2
qq.vue
src/components/qq.vue
+58
-55
setl.vue
src/components/setl.vue
+64
-0
xyz.vue
src/components/xyz.vue
+58
-0
lonlat.js
src/js/lonlat.js
+0
-0
No files found.
src/App.vue
View file @
8927f7fd
...
@@ -13,9 +13,12 @@ import baozha from './components/baozha.vue'
...
@@ -13,9 +13,12 @@ import baozha from './components/baozha.vue'
import
kedupan
from
'./components/kedupan.vue'
import
kedupan
from
'./components/kedupan.vue'
import
raotaiyang
from
'./components/raotaiyng.vue'
import
raotaiyang
from
'./components/raotaiyng.vue'
import
qq
from
'./components/qq.vue'
import
qq
from
'./components/qq.vue'
import
setl
from
'./components/setl.vue'
import
xyz
from
'./components/xyz.vue'
export
default
{
export
default
{
name
:
'app'
,
name
:
'app'
,
components
:
{
boom
,
demo
,
draw
,
moon
,
fire
,
selt
,
sun
,
camera
,
dail
,
baozha
,
kedupan
,
raotaiyang
,
qq
}
components
:
{
boom
,
demo
,
draw
,
moon
,
fire
,
selt
,
sun
,
camera
,
dail
,
baozha
,
kedupan
,
raotaiyang
,
qq
,
setl
,
xyz
}
}
}
</
script
>
</
script
>
...
@@ -31,8 +34,10 @@ export default {
...
@@ -31,8 +34,10 @@ export default {
<!--
<draw/>
-->
<!--
<draw/>
-->
<!--
<camera/>
-->
<!--
<camera/>
-->
<!--
<dail/>
-->
<!--
<dail/>
-->
<
raotaiyang/
>
<
!--
<raotaiyang/>
--
>
<!--
<qq/>
-->
<!--
<qq/>
-->
<xyz/>
<!--
<setl/>
-->
</
template
>
</
template
>
<
style
scoped
>
<
style
scoped
>
...
...
src/components/qq.vue
View file @
8927f7fd
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
<
script
setup
>
<
script
setup
>
import
{
onMounted
}
from
'vue'
import
{
onMounted
}
from
'vue'
import
*
as
Cesium
from
'cesium'
import
*
as
Cesium
from
'cesium'
import
Cesium3DTile
from
'cesium/Source/Scene/Cesium3DTile'
;
onMounted
(()
=>
{
onMounted
(()
=>
{
...
@@ -16,15 +17,32 @@ onMounted(() => {
...
@@ -16,15 +17,32 @@ onMounted(() => {
let
handler
;
let
handler
;
// 添加轨迹线实体
// 添加轨迹线实体
const
polyline
=
viewer
.
entities
.
add
({
viewer
.
entities
.
add
({
id
:
'polyline'
,
id
:
'polyline'
,
polyline
:
{
position
:
Cesium
.
Cartesian3
.
fromDegrees
(
-
75.59777
,
40.03883
,
300000
),
positions
:
Cesium
.
Cartesian3
.
fromDegreesArray
([
-
100
,
20
,
-
100
,
30
,
-
90
,
25
]),
ellipsoid
:
{
width
:
20
,
radii
:
new
Cesium
.
Cartesian3
(
200000.0
,
200000.0
,
200000.0
),
material
:
Cesium
.
Color
.
YELLOW
,
}
},
});
});
const
polyline
=
viewer
.
entities
.
add
({
id
:
'line'
,
polyline
:
{
positions
:
Cesium
.
Cartesian3
.
fromDegreesArray
([
-
70
,
30
,
-
60
,
20
,
-
50
,
30
]),
width
:
2
,
material
:
Cesium
.
Color
.
YELLOW
}
})
viewer
.
entities
.
add
({
id
:
"point"
,
position
:
Cesium
.
Cartesian3
.
fromDegrees
(
-
85
,
30
,
100
),
point
:
{
pixelSize
:
10
,
color
:
Cesium
.
Color
.
RED
}
})
// 添加用于显示标签的实体
// 添加用于显示标签的实体
const
entity
=
viewer
.
entities
.
add
({
const
entity
=
viewer
.
entities
.
add
({
label
:
{
label
:
{
...
@@ -34,79 +52,64 @@ onMounted(() => {
...
@@ -34,79 +52,64 @@ onMounted(() => {
horizontalOrigin
:
Cesium
.
HorizontalOrigin
.
LEFT
,
horizontalOrigin
:
Cesium
.
HorizontalOrigin
.
LEFT
,
verticalOrigin
:
Cesium
.
VerticalOrigin
.
TOP
,
verticalOrigin
:
Cesium
.
VerticalOrigin
.
TOP
,
pixelOffset
:
new
Cesium
.
Cartesian2
(
15
,
0
),
pixelOffset
:
new
Cesium
.
Cartesian2
(
15
,
0
),
eyeOffset
:
new
Cesium
.
Cartesian3
(
0
,
0
,
-
10000
)
},
},
});
});
// 设置鼠标事件处理器
// 设置鼠标事件处理器
handler
=
new
Cesium
.
ScreenSpaceEventHandler
(
scene
.
canvas
);
handler
=
new
Cesium
.
ScreenSpaceEventHandler
(
scene
.
canvas
);
// 处理鼠标移动事件
handler
.
setInputAction
(
function
(
movement
)
{
handler
.
setInputAction
(
function
(
movement
)
{
const
pickedObject
=
viewer
.
scene
.
pick
(
movement
.
endPosition
);
if
(
Cesium
.
defined
(
pickedObject
)
&&
pickedObject
.
id
&&
pickedObject
.
id
.
id
===
'polyline'
)
{
const
cartesian
=
viewer
.
camera
.
pickEllipsoid
(
const
cartesian
=
viewer
.
camera
.
pickEllipsoid
(
movement
.
endPosition
,
movement
.
endPosition
,
scene
.
globe
.
ellipsoid
scene
.
globe
.
ellipsoid
);
);
if
(
cartesian
)
{
const
cartographic
=
Cesium
.
Cartographic
.
fromCartesian
(
cartesian
);
const
longitudeString
=
Cesium
.
Math
.
toDegrees
(
cartographic
.
longitude
).
toFixed
(
2
);
const
latitudeString
=
Cesium
.
Math
.
toDegrees
(
cartographic
.
latitude
).
toFixed
(
2
);
const
heightString
=
cartographic
.
height
.
toFixed
(
2
);
const
xString
=
cartesian
.
x
.
toFixed
(
2
);
const
yString
=
cartesian
.
y
.
toFixed
(
2
);
const
zString
=
cartesian
.
z
.
toFixed
(
2
);
entity
.
position
=
cartesian
;
entity
.
label
.
show
=
true
;
entity
.
label
.
text
=
`Lon:
${
`
${
longitudeString
}
`
.
slice
(
-
7
)}
\u00B0`
+
`\nLat:
${
`
${
latitudeString
}
`
.
slice
(
-
7
)}
\u00B0`
+
`\nHeight:
${
heightString
}
m`
+
`\n\nECEF:`
+
`\nX:
${
xString
}
m`
+
`\nY:
${
yString
}
m`
+
`\nZ:
${
zString
}
m`
;
}
}
else
{
entity
.
label
.
show
=
false
;
}
},
Cesium
.
ScreenSpaceEventType
.
MOUSE_MOVE
);
handler
.
setInputAction
(
function
(
movement
)
{
const
pickedObject
=
viewer
.
scene
.
pick
(
movement
.
position
);
if
(
Cesium
.
defined
(
pickedObject
)
&&
pickedObject
.
id
&&
pickedObject
.
id
.
id
===
'polyline'
)
{
const
cartesian
=
viewer
.
camera
.
pickEllipsoid
(
movement
.
position
,
scene
.
globe
.
ellipsoid
);
if
(
cartesian
)
{
if
(
cartesian
)
{
// 从笛卡尔坐标转换为地理坐标
const
cartographic
=
Cesium
.
Cartographic
.
fromCartesian
(
cartesian
);
const
cartographic
=
Cesium
.
Cartographic
.
fromCartesian
(
cartesian
);
const
longitudeString
=
Cesium
.
Math
.
toDegrees
(
cartographic
.
longitude
).
toFixed
(
2
);
const
longitudeString
=
Cesium
.
Math
.
toDegrees
(
cartographic
.
longitude
).
toFixed
(
2
);
const
latitudeString
=
Cesium
.
Math
.
toDegrees
(
cartographic
.
latitude
).
toFixed
(
2
);
const
latitudeString
=
Cesium
.
Math
.
toDegrees
(
cartographic
.
latitude
).
toFixed
(
2
);
const
heightString
=
cartographic
.
height
.
toFixed
(
2
);
const
heightString
=
cartographic
.
height
.
toFixed
(
2
);
const
xString
=
cartesian
.
x
.
toFixed
(
2
);
// 将笛卡尔坐标转换为字符串
const
yString
=
cartesian
.
y
.
toFixed
(
2
);
const
cartesianString
=
`X:
${
cartesian
.
x
.
toFixed
(
2
)}
, Y:
${
cartesian
.
y
.
toFixed
(
2
)}
, Z:
${
cartesian
.
z
.
toFixed
(
2
)}
`
;
const
zString
=
cartesian
.
z
.
toFixed
(
2
);
entity
.
position
=
cartesian
;
entity
.
position
=
cartesian
;
entity
.
label
.
show
=
true
;
entity
.
label
.
show
=
true
;
entity
.
label
.
text
=
entity
.
label
.
text
=
`Lon:
${
`
${
longitudeString
}
`
.
slice
(
-
7
)}
\u00B0`
+
`X:
${
cartesian
.
x
.
toFixed
(
2
)}
`
+
`\nLat:
${
`
${
latitudeString
}
`
.
slice
(
-
7
)}
\u00B0`
+
`\nY:
${
cartesian
.
y
.
toFixed
(
2
)}
`
+
`\nHeight:
${
heightString
}
m`
+
`\nZ:
${
cartesian
.
z
.
toFixed
(
2
)}
`
;
`\n\nECEF:`
+
`\nX:
${
xString
}
m`
+
`\nY:
${
yString
}
m`
+
`\nZ:
${
zString
}
m`
;
}
}
else
{
}
else
{
entity
.
label
.
show
=
false
;
entity
.
label
.
show
=
false
;
}
}
},
Cesium
.
ScreenSpaceEventType
.
LEFT_CLICK
);
},
Cesium
.
ScreenSpaceEventType
.
MOUSE_MOVE
);
// handler.setInputAction(function (movement) {
// const cartesian = viewer.camera.pickEllipsoid(
// movement.endPosition,
// scene.globe.ellipsoid
// );
// if (cartesian) {
// const pickedEntity = viewer.scene.pick(movement.endPosition);
// if (Cesium.defined(pickedEntity) && pickedEntity.id) {
// const entityPosition = Cesium.Cartographic.fromCartesian(pickedEntity.id.position.getValue(viewer.clock.currentTime));
// const longitudeString = Cesium.Math.toDegrees(entityPosition.longitude).toFixed(2);
// const latitudeString = Cesium.Math.toDegrees(entityPosition.latitude).toFixed(2);
// const heightString = entityPosition.height.toFixed(2);
// entity.position = cartesian;
// entity.label.show = true;
// entity.label.text =
// `Lon: ${longitudeString}\u00B0` +
// `\nLat: ${latitudeString}\u00B0`;
// } else {
// entity.label.show = false;
// }
// } else {
// entity.label.show = false;
// }
// }, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
...
...
src/components/setl.vue
0 → 100644
View file @
8927f7fd
<
template
>
<div
id=
"cesiumContainer"
class=
"all"
></div>
</
template
>
<
script
setup
>
import
{
onMounted
}
from
'vue'
import
*
as
Cesium
from
'cesium'
onMounted
(()
=>
{
Cesium
.
Ion
.
defaultAccessToken
=
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyYTI3MDQxMS1hYzgxLTRlYTQtODExZS00YzdmYjM0YTg3OTAiLCJpZCI6MjI0NzQzLCJpYXQiOjE3MTkzOTcxMDF9._VD-W1rEy7jSUtPmcVytEYbZIZ00_IeHCZm59Kua5aE'
const
viewer
=
new
Cesium
.
Viewer
(
"cesiumContainer"
,
{
})
const
scene
=
viewer
.
scene
;
let
handler
;
// 添加用于显示标签的实体
const
entity
=
viewer
.
entities
.
add
({
label
:
{
show
:
false
,
showBackground
:
true
,
font
:
"16px monospace"
,
horizontalOrigin
:
Cesium
.
HorizontalOrigin
.
LEFT
,
verticalOrigin
:
Cesium
.
VerticalOrigin
.
TOP
,
pixelOffset
:
new
Cesium
.
Cartesian2
(
15
,
0
),
eyeOffset
:
new
Cesium
.
Cartesian3
(
0
,
0
,
-
10000
)
},
});
// 设置鼠标事件处理器
handler
=
new
Cesium
.
ScreenSpaceEventHandler
(
scene
.
canvas
);
handler
.
setInputAction
(
function
(
movement
)
{
const
cartesian
=
viewer
.
camera
.
pickEllipsoid
(
movement
.
endPosition
,
scene
.
globe
.
ellipsoid
);
if
(
cartesian
)
{
const
cartographic
=
Cesium
.
Cartographic
.
fromCartesian
(
cartesian
);
const
longitudeString
=
Cesium
.
Math
.
toDegrees
(
cartographic
.
longitude
).
toFixed
(
2
);
const
latitudeString
=
Cesium
.
Math
.
toDegrees
(
cartographic
.
latitude
).
toFixed
(
2
);
entity
.
position
=
cartesian
;
entity
.
label
.
show
=
true
;
entity
.
label
.
text
=
`Lon:
${
`
${
longitudeString
}
`
.
slice
(
-
7
)}
\u00B0`
+
`\nLat:
${
`
${
latitudeString
}
`
.
slice
(
-
7
)}
\u00B0`
;
}
else
{
entity
.
label
.
show
=
false
;
}
},
Cesium
.
ScreenSpaceEventType
.
MOUSE_MOVE
);
})
</
script
>
<
style
>
.all
{
display
:
block
;
position
:
absolute
;
top
:
0
;
left
:
0
;
border
:
none
;
width
:
100%
;
height
:
100%
}
</
style
>
src/components/xyz.vue
0 → 100644
View file @
8927f7fd
<
template
>
<div
id=
"cesiumContainer"
class=
"all"
></div>
</
template
>
<
script
setup
>
import
{
onMounted
}
from
'vue'
import
*
as
Cesium
from
'cesium'
onMounted
(()
=>
{
Cesium
.
Ion
.
defaultAccessToken
=
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyYTI3MDQxMS1hYzgxLTRlYTQtODExZS00YzdmYjM0YTg3OTAiLCJpZCI6MjI0NzQzLCJpYXQiOjE3MTkzOTcxMDF9._VD-W1rEy7jSUtPmcVytEYbZIZ00_IeHCZm59Kua5aE'
const
viewer
=
new
Cesium
.
Viewer
(
"cesiumContainer"
,
{
})
const
scene
=
viewer
.
scene
;
let
handler
;
// 添加用于显示标签的实体
const
entity
=
viewer
.
entities
.
add
({
label
:
{
show
:
false
,
showBackground
:
true
,
font
:
"16px monospace"
,
horizontalOrigin
:
Cesium
.
HorizontalOrigin
.
LEFT
,
verticalOrigin
:
Cesium
.
VerticalOrigin
.
TOP
,
pixelOffset
:
new
Cesium
.
Cartesian2
(
15
,
0
),
eyeOffset
:
new
Cesium
.
Cartesian3
(
0
,
0
,
-
10000
)
},
});
// 设置鼠标事件处理器
handler
=
new
Cesium
.
ScreenSpaceEventHandler
(
scene
.
canvas
);
handler
.
setInputAction
(
function
(
movement
)
{
const
cartesian
=
viewer
.
camera
.
pickEllipsoid
(
movement
.
endPosition
,
scene
.
globe
.
ellipsoid
);
if
(
cartesian
)
{
entity
.
position
=
cartesian
;
entity
.
label
.
show
=
true
;
entity
.
label
.
text
=
`X:
${
cartesian
.
x
.
toFixed
(
2
)}
`
+
`\nY:
${
cartesian
.
y
.
toFixed
(
2
)}
`
+
`\nZ:
${
cartesian
.
z
.
toFixed
(
2
)}
`
;
}
else
{
entity
.
label
.
show
=
false
;
}
},
Cesium
.
ScreenSpaceEventType
.
MOUSE_MOVE
);
})
</
script
>
<
style
>
.all
{
display
:
block
;
position
:
absolute
;
top
:
0
;
left
:
0
;
border
:
none
;
width
:
100%
;
height
:
100%
}
</
style
>
src/js/lonlat.js
0 → 100644
View file @
8927f7fd
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