Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zhengyuan-danger-chemistry-manage
Project
Project
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
耿迪迪
zhengyuan-danger-chemistry-manage
Commits
fbcec390
Commit
fbcec390
authored
Mar 15, 2023
by
纪泽龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
可漫游版本
parent
2d41b9db
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
137 additions
and
9 deletions
+137
-9
cesiumClass.js
danger-manage-web/src/utils/cesium/cesiumClass.js
+76
-8
cesiumRoamStart.js
danger-manage-web/src/utils/cesium/cesiumRoamStart.js
+59
-0
index.vue
danger-manage-web/src/views/index.vue
+2
-1
No files found.
danger-manage-web/src/utils/cesium/cesiumClass.js
View file @
fbcec390
/*
* @Author: your name
* @Date: 2021-12-07 14:19:18
* @LastEditTime: 2023-03-1
0 11:16:03
* @LastEditTime: 2023-03-1
5 16:47:50
* @LastEditors: 纪泽龙 jizelong@qq.com
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @FilePath: /cesium-vue/src/utils/seieumClass.js
*/
import
gcoord
from
"gcoord"
;
import
AroundPoint
from
"./cesiumRoamStart"
;
const
MAPTYPE
=
{
gps
:
"WGS84"
,
gaode
:
"GCJ02"
,
...
...
@@ -184,6 +185,8 @@ export default class CreateCesium {
infowindowTimer
=
null
;
// 用来记录同频定时器的timer
animationTimer
=
null
;
// 一个漫游对象,从外部引入new的类
roamObj
=
null
;
constructor
(
container
,
urlArr
,
Vue
,
config
)
{
this
.
vue
=
Vue
;
console
.
log
(
"Vue"
,
this
.
vue
.
$store
);
...
...
@@ -332,6 +335,8 @@ export default class CreateCesium {
// nowLngLat = (await this.gpsToGaode(gps))[0];
nowLngLat
=
this
.
gaodeToGps
(
lnglat
,
item
);
}
// 漫游旋转用的坐标
this
.
romanLngLat
=
nowLngLat
;
console
.
log
(
"坐标换算完毕123123123123123123"
,
nowLngLat
);
// AMap.convertFrom(gps, "gps", (status, result) =>{
// if (result.info === "ok") {
...
...
@@ -382,12 +387,12 @@ export default class CreateCesium {
// heading: 1.6454928984350525, // 方向
// pitch: -1.0974068412623752, // 倾斜角度
// roll: 0.00004639407505457882,
// heading: Cesium.Math.toRadians(
2
0.0), // 方向
// pitch: Cesium.Math.toRadians(-
90
.0,), // 倾斜角度
// roll:
1.3
,
heading
:
Cesium
.
Math
.
toRadians
(
0
),
// 方向
pitch
:
Cesium
.
Math
.
toRadians
(
-
81.61
),
// 倾斜角度
// roll: 1.3
,
// heading: Cesium.Math.toRadians(0.0), // 方向
// pitch: Cesium.Math.toRadians(-
81
.0,), // 倾斜角度
// roll:
5
,
heading
:
1.5882496193148399
,
pitch
:
-
1.5707963057214722
,
},
duration
:
0.1
,
//定位的时间间隔
});
...
...
@@ -403,6 +408,68 @@ export default class CreateCesium {
});
});
}
// 围绕点漫游
roamStart
()
{
if
(
this
.
roamObj
)
return
;
var
heading
=
this
.
viewer
.
scene
.
camera
.
heading
;
var
pitch
=
this
.
viewer
.
scene
.
camera
.
pitch
;
this
.
viewer
.
scene
.
camera
.
flyTo
({
destination
:
Cesium
.
Cartesian3
.
fromDegrees
(
// 114.08040670822453,
// 38.24912720167037,
...
this
.
romanLngLat
,
200
),
//定位坐标点,建议使用谷歌地球坐标位置无偏差
orientation
:
{
// heading: 1.6454928984350525, // 方向
// pitch: -1.0974068412623752, // 倾斜角度
// roll: 0.00004639407505457882,
// heading: Cesium.Math.toRadians(20.0), // 方向
// pitch: Cesium.Math.toRadians(-90.0,), // 倾斜角度
// heading: 1.5882496193148399,
// pitch: -1.5707963057214722,
},
duration
:
1
,
//定位的时间间隔
complete
:
()
=>
{
console
.
log
(
"开始漫游"
);
this
.
roamObj
=
new
AroundPoint
(
this
.
viewer
,
0.2
,
new
Cesium
.
Cartesian3
.
fromDegrees
(...
this
.
romanLngLat
),
200
,
// 1.5882496193148399,
// -1.5707963057214722
);
this
.
roamObj
.
start
();
},
});
}
roamStop
()
{
if
(
!
this
.
roamObj
)
return
;
this
.
roamObj
.
stop
();
this
.
roamObj
=
null
;
}
getcameraPosInfo
()
{
// 获取 相机姿态信息
var
head
=
viewer
.
scene
.
camera
.
heading
;
var
pitch
=
viewer
.
scene
.
camera
.
pitch
;
var
roll
=
viewer
.
scene
.
camera
.
roll
;
var
info
=
{
head
:
head
,
pitch
:
pitch
,
roll
:
roll
};
// 获取位置 wgs84的地心坐标系,x,y坐标值以弧度来表示
var
position
=
viewer
.
scene
.
camera
.
positionCartographic
;
//with longitude and latitude expressed in radians and height in meters.
//以下方式也可以获取相机位置只是返回的坐标系不一样
// var position = viewer.scene.camera.position //cartesian3 空间直角坐标系
// var ellipsoid = scene.globe.ellipsoid;
// var position =ellipsoid.cartesianToCartographic(viewer.scene.camera.position)//
// 弧度转经纬度
var
longitude
=
Cesium
.
Math
.
toDegrees
(
position
.
longitude
).
toFixed
(
6
);
var
latitude
=
Cesium
.
Math
.
toDegrees
(
position
.
latitude
).
toFixed
(
6
);
var
height
=
position
.
height
;
return
{
lng
:
longitude
,
lat
:
latitude
,
h
:
height
,
mat
:
info
};
}
// 增加事件监听
posLng
=
null
;
...
...
@@ -596,8 +663,9 @@ export default class CreateCesium {
// );
},
Cesium
.
ScreenSpaceEventType
.
WHEEL
);
// 摄像机监听
this
.
viewer
.
camera
.
changed
.
addEventListener
((
percentage
)
=>
{
this
.
viewer
.
camera
.
changed
.
addEventListener
((
percentage
,
b
)
=>
{
// 打印中心点坐标、高度
// console.log(this.viewer.camera)
// 当鼠地图移动的时候与相机事件隔离
if
(
!
this
.
mouseDownFlag
)
{
// console.log("相机发生变化");
...
...
danger-manage-web/src/utils/cesium/cesiumRoamStart.js
0 → 100644
View file @
fbcec390
/*
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2023-03-15 13:49:30
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-03-15 16:46:54
* @FilePath: /danger-manage-web/src/utils/cesium/cesiumRoamStart.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
export
default
class
AroundPoint
{
constructor
(
viewer
,
amount
,
position
,
height
,
heading
,
pitch
)
{
this
.
_viewer
=
viewer
;
this
.
_amount
=
amount
;
this
.
_position
=
position
;
this
.
height
=
height
;
this
.
heading
=
heading
;
this
.
pitch
=
pitch
;
}
_bindEvent
()
{
this
.
_viewer
.
clock
.
onTick
.
addEventListener
(
this
.
_aroundPoint
,
this
);
}
_unbindEvent
()
{
this
.
_viewer
.
camera
.
lookAtTransform
(
Cesium
.
Matrix4
.
IDENTITY
);
this
.
_viewer
.
clock
.
onTick
.
removeEventListener
(
this
.
_aroundPoint
,
this
);
}
start
()
{
this
.
_viewer
.
clock
.
shouldAnimate
=
true
;
this
.
_unbindEvent
();
this
.
_bindEvent
();
return
this
;
}
stop
()
{
this
.
_unbindEvent
();
return
this
;
}
// 相机绕点旋转函数
_aroundPoint
()
{
let
heading
=
this
.
_viewer
.
camera
.
heading
;
let
pitch
=
this
.
_viewer
.
camera
.
pitch
;
// console.log(Cesium.Math.toRadians(this._amount))
heading
+=
Cesium
.
Math
.
toRadians
(
this
.
_amount
);
if
(
heading
>=
Math
.
PI
*
2
||
heading
<=
-
Math
.
PI
*
2
)
{
heading
=
0
}
// 用新坐标替换旧坐标
this
.
heading
=
heading
;
this
.
pitch
=
pitch
;
this
.
_viewer
.
camera
.
lookAt
(
this
.
_position
,
new
Cesium
.
HeadingPitchRange
(
heading
,
pitch
,
this
.
height
)
);
}
}
danger-manage-web/src/views/index.vue
View file @
fbcec390
...
...
@@ -2,7 +2,7 @@
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2022-09-03 10:51:24
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-03-1
4 09:39:00
* @LastEditTime: 2023-03-1
5 14:13:15
* @FilePath: /danger-manage-web/src/views/index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
...
...
@@ -386,6 +386,7 @@ export default {
this
);
this
.
init
();
window
.
C
=
this
.
Cesium
;
},
beforeDestroy
()
{
// 挂掉该关的 infowindow 跟计算infowindow位置的计时器
...
...
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