1
-
2
- import { defined , Camera , Rectangle , Cartographic , Math as CesiumMath } from 'cesium'
3
- import svgReset from '../svgPaths/svgReset'
4
- import NavigationControl from './NavigationControl'
1
+ import {
2
+ defined ,
3
+ Camera ,
4
+ Rectangle ,
5
+ Cartographic ,
6
+ Math as CesiumMath ,
7
+ } from "cesium" ;
8
+ import svgReset from "../svgPaths/svgReset" ;
9
+ import NavigationControl from "./NavigationControl" ;
5
10
6
11
/**
7
12
* The model for a zoom in control in the navigation control tool bar
@@ -13,101 +18,122 @@ import NavigationControl from './NavigationControl'
13
18
* @param {Terria } terria The Terria instance.
14
19
*/
15
20
var ResetViewNavigationControl = function ( terria ) {
16
- NavigationControl . apply ( this , arguments )
21
+ NavigationControl . apply ( this , arguments ) ;
17
22
18
23
/**
19
24
* Gets or sets the name of the control which is set as the control's title.
20
25
* This property is observable.
21
26
* @type {String }
22
27
*/
23
- this . name = terria . options . resetTooltip ? terria . options . resetTooltip : '重置视图'
24
- this . navigationLocked = false
28
+ this . name = terria . options . resetTooltip
29
+ ? terria . options . resetTooltip
30
+ : "重置视图" ;
31
+ this . navigationLocked = false ;
25
32
26
33
/**
27
34
* Gets or sets the svg icon of the control. This property is observable.
28
35
* @type {Object }
29
36
*/
30
- this . svgIcon = terria . options . resetSvg ? "" : svgReset
31
- this . resetSvg = terria . options . resetSvg
37
+ this . svgIcon = terria . options . resetSvg ? "" : svgReset ;
38
+ this . resetSvg = terria . options . resetSvg ;
39
+ this . resetSuccess = terria . options . resetSuccess ;
40
+
32
41
/**
33
42
* Gets or sets the height of the svg icon. This property is observable.
34
43
* @type {Integer }
35
44
*/
36
- this . svgHeight = 15
45
+ this . svgHeight = 15 ;
37
46
38
47
/**
39
48
* Gets or sets the width of the svg icon. This property is observable.
40
49
* @type {Integer }
41
50
*/
42
- this . svgWidth = 15
51
+ this . svgWidth = 15 ;
43
52
44
53
/**
45
54
* Gets or sets the CSS class of the control. This property is observable.
46
55
* @type {String }
47
56
*/
48
- this . cssClass = ' navigation-control-icon-reset'
49
- }
57
+ this . cssClass = " navigation-control-icon-reset" ;
58
+ } ;
50
59
51
- ResetViewNavigationControl . prototype = Object . create ( NavigationControl . prototype )
60
+ ResetViewNavigationControl . prototype = Object . create (
61
+ NavigationControl . prototype
62
+ ) ;
52
63
53
64
ResetViewNavigationControl . prototype . setNavigationLocked = function ( locked ) {
54
- this . navigationLocked = locked
55
- }
65
+ this . navigationLocked = locked ;
66
+ } ;
56
67
57
68
ResetViewNavigationControl . prototype . resetView = function ( ) {
58
69
// this.terria.analytics.logEvent('navigation', 'click', 'reset');
59
70
if ( this . navigationLocked ) {
60
- return
71
+ return ;
61
72
}
62
- var scene = this . terria . scene
73
+ var scene = this . terria . scene ;
63
74
64
- var sscc = scene . screenSpaceCameraController
75
+ var sscc = scene . screenSpaceCameraController ;
65
76
if ( ! sscc . enableInputs ) {
66
- return
77
+ return ;
67
78
}
68
79
69
- this . isActive = true
80
+ this . isActive = true ;
70
81
71
- var camera = scene . camera
82
+ var camera = scene . camera ;
72
83
73
84
if ( defined ( this . terria . trackedEntity ) ) {
74
85
// when tracking do not reset to default view but to default view of tracked entity
75
- var trackedEntity = this . terria . trackedEntity
76
- this . terria . trackedEntity = undefined
77
- this . terria . trackedEntity = trackedEntity
86
+ var trackedEntity = this . terria . trackedEntity ;
87
+ this . terria . trackedEntity = undefined ;
88
+ this . terria . trackedEntity = trackedEntity ;
78
89
} else {
79
90
// reset to a default position or view defined in the options
80
- const duration = this . terria . options . duration ? this . terria . options . duration : 3
91
+ const duration = this . terria . options . duration
92
+ ? this . terria . options . duration
93
+ : 3 ;
81
94
if ( this . terria . options . defaultResetView ) {
82
- const orientation = this . terria . options . orientation ? this . terria . options . orientation : {
83
- heading : CesiumMath . toRadians ( 5.729578 )
84
- }
85
- if ( this . terria . options . defaultResetView && this . terria . options . defaultResetView instanceof Cartographic ) {
95
+ const orientation = this . terria . options . orientation
96
+ ? this . terria . options . orientation
97
+ : {
98
+ heading : CesiumMath . toRadians ( 5.729578 ) ,
99
+ } ;
100
+ if (
101
+ this . terria . options . defaultResetView &&
102
+ this . terria . options . defaultResetView instanceof Cartographic
103
+ ) {
86
104
camera . flyTo ( {
87
- destination : scene . globe . ellipsoid . cartographicToCartesian ( this . terria . options . defaultResetView ) ,
105
+ destination : scene . globe . ellipsoid . cartographicToCartesian (
106
+ this . terria . options . defaultResetView
107
+ ) ,
88
108
orientation,
89
- duration
90
- } )
91
- } else if ( this . terria . options . defaultResetView && this . terria . options . defaultResetView instanceof Rectangle ) {
109
+ duration,
110
+ } ) ;
111
+ } else if (
112
+ this . terria . options . defaultResetView &&
113
+ this . terria . options . defaultResetView instanceof Rectangle
114
+ ) {
92
115
try {
93
- Rectangle . validate ( this . terria . options . defaultResetView )
116
+ Rectangle . validate ( this . terria . options . defaultResetView ) ;
94
117
camera . flyTo ( {
95
118
destination : this . terria . options . defaultResetView ,
96
119
orientation,
97
- duration
98
- } )
120
+ duration,
121
+ complete : this . resetSuccess ,
122
+ } ) ;
99
123
} catch ( e ) {
100
- console . log ( 'Cesium-navigation/ResetViewNavigationControl: options.defaultResetView Cesium rectangle is invalid!' )
124
+ console . log (
125
+ "Cesium-navigation/ResetViewNavigationControl: options.defaultResetView Cesium rectangle is invalid!"
126
+ ) ;
101
127
}
102
128
}
103
- } else if ( typeof camera . flyHome === ' function' ) {
104
- camera . flyHome ( 1 )
129
+ } else if ( typeof camera . flyHome === " function" ) {
130
+ camera . flyHome ( 1 ) ;
105
131
} else {
106
- camera . flyTo ( { destination : Camera . DEFAULT_VIEW_RECTANGLE , duration } )
132
+ camera . flyTo ( { destination : Camera . DEFAULT_VIEW_RECTANGLE , duration } ) ;
107
133
}
108
134
}
109
- this . isActive = false
110
- }
135
+ this . isActive = false ;
136
+ } ;
111
137
112
138
/**
113
139
* When implemented in a derived class, performs an action when the user clicks
@@ -116,7 +142,7 @@ ResetViewNavigationControl.prototype.resetView = function () {
116
142
* @protected
117
143
*/
118
144
ResetViewNavigationControl . prototype . activate = function ( ) {
119
- this . resetView ( )
120
- }
145
+ this . resetView ( ) ;
146
+ } ;
121
147
122
- export default ResetViewNavigationControl
148
+ export default ResetViewNavigationControl ;
0 commit comments