File tree Expand file tree Collapse file tree 3 files changed +53
-5
lines changed
src/components/mars-work/expand Expand file tree Collapse file tree 3 files changed +53
-5
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import "mars3d-mapv"
88// 注册mars3d插件 【授权版】
99// import "mars3d/plugins/space/mars3d-space"
1010
11- // 注册mars3d继承的相关类
11+ // 注册mars3d继承的相关类[非必须,演示Task集成的]
1212import "./task/CameraList.js"
1313import "./task/CameraView.js"
1414import "./task/MapRotate.js"
@@ -18,6 +18,6 @@ import "./task/ZoomIn.js"
1818import "./task/ZoomOut.js"
1919import "./task/GraphicStyle.js"
2020import "./task/CreateTarget.js"
21-
21+ import "./task/SceneOptions.js"
2222
2323import "./graphic/CanvasBillboard.js"
Original file line number Diff line number Diff line change 11import * as mars3d from "mars3d"
2+ const Cesium = mars3d . Cesium
23
34/**
45 * 进入时创建对象,离开时销毁对象
@@ -89,9 +90,13 @@ class CreateTarget extends mars3d.TaskItem {
8990 } )
9091 delete this . _effects
9192 }
93+
94+ if ( this . _controls ) {
95+ this . _controls . forEach ( ( control ) => {
96+ control . remove ( true )
97+ } )
98+ delete this . _controls
99+ }
92100 }
93101}
94102mars3d . thing . Task . register ( "createTarget" , CreateTarget )
95-
96-
97-
Original file line number Diff line number Diff line change 1+ import * as mars3d from "mars3d"
2+ const Cesium = mars3d . Cesium
3+
4+ /**
5+ * 修改地图上场景参数值(比如切换到二维视图)
6+ *
7+ * @param {object } [options] 参数对象,包括以下:
8+ * @param {string } [options.name] 标题名称
9+ * @param {string } [options.type] 类型标识,自动赋值的,无需手动传入
10+ * @param {number } [options.start] 开始时间,相当于map.clock.startTime的秒数
11+ * @param {number } [options.duration] 时长
12+ *
13+ * @param {mars3d.Map.sceneOptions } [options.scene] 需要修改的场景参数,原参数中必须有对应键值否则无法还原。
14+ */
15+ class SceneOptions extends mars3d . TaskItem {
16+ // 进入,激活开始处理事务
17+ _activateWork ( ) {
18+ const newOptions = this . options . scene
19+ const oldOptions = { }
20+
21+ const noKey = [ ]
22+ for ( const key in newOptions ) {
23+ if ( Cesium . defined ( this . _map . options . scene [ key ] ) ) {
24+ oldOptions [ key ] = this . _map . options . scene [ key ]
25+ } else {
26+ noKey . push ( key )
27+ }
28+ }
29+ if ( noKey . length > 0 ) {
30+ console . log ( "SceneOptions:原有场景参数中不存在以下属性,关闭时将无法恢复" , noKey )
31+ }
32+
33+ this . _oldOptions = oldOptions
34+ this . _map . setSceneOptions ( newOptions )
35+ }
36+
37+ // 离开,释放相关对象
38+ _disableWork ( ) {
39+ this . _map . setSceneOptions ( this . _oldOptions )
40+ delete this . _oldOptions
41+ }
42+ }
43+ mars3d . thing . Task . register ( "sceneOptions" , SceneOptions )
You can’t perform that action at this time.
0 commit comments