Skip to content

Commit d46bba0

Browse files
committed
add3.0.9
1 parent 57f3337 commit d46bba0

File tree

3 files changed

+76
-50
lines changed

3 files changed

+76
-50
lines changed

dist/CesiumNavigation.umd.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 72 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
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";
510

611
/**
712
* The model for a zoom in control in the navigation control tool bar
@@ -13,101 +18,122 @@ import NavigationControl from './NavigationControl'
1318
* @param {Terria} terria The Terria instance.
1419
*/
1520
var ResetViewNavigationControl = function (terria) {
16-
NavigationControl.apply(this, arguments)
21+
NavigationControl.apply(this, arguments);
1722

1823
/**
1924
* Gets or sets the name of the control which is set as the control's title.
2025
* This property is observable.
2126
* @type {String}
2227
*/
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;
2532

2633
/**
2734
* Gets or sets the svg icon of the control. This property is observable.
2835
* @type {Object}
2936
*/
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+
3241
/**
3342
* Gets or sets the height of the svg icon. This property is observable.
3443
* @type {Integer}
3544
*/
36-
this.svgHeight = 15
45+
this.svgHeight = 15;
3746

3847
/**
3948
* Gets or sets the width of the svg icon. This property is observable.
4049
* @type {Integer}
4150
*/
42-
this.svgWidth = 15
51+
this.svgWidth = 15;
4352

4453
/**
4554
* Gets or sets the CSS class of the control. This property is observable.
4655
* @type {String}
4756
*/
48-
this.cssClass = 'navigation-control-icon-reset'
49-
}
57+
this.cssClass = "navigation-control-icon-reset";
58+
};
5059

51-
ResetViewNavigationControl.prototype = Object.create(NavigationControl.prototype)
60+
ResetViewNavigationControl.prototype = Object.create(
61+
NavigationControl.prototype
62+
);
5263

5364
ResetViewNavigationControl.prototype.setNavigationLocked = function (locked) {
54-
this.navigationLocked = locked
55-
}
65+
this.navigationLocked = locked;
66+
};
5667

5768
ResetViewNavigationControl.prototype.resetView = function () {
5869
// this.terria.analytics.logEvent('navigation', 'click', 'reset');
5970
if (this.navigationLocked) {
60-
return
71+
return;
6172
}
62-
var scene = this.terria.scene
73+
var scene = this.terria.scene;
6374

64-
var sscc = scene.screenSpaceCameraController
75+
var sscc = scene.screenSpaceCameraController;
6576
if (!sscc.enableInputs) {
66-
return
77+
return;
6778
}
6879

69-
this.isActive = true
80+
this.isActive = true;
7081

71-
var camera = scene.camera
82+
var camera = scene.camera;
7283

7384
if (defined(this.terria.trackedEntity)) {
7485
// 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;
7889
} else {
7990
// 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;
8194
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+
) {
86104
camera.flyTo({
87-
destination: scene.globe.ellipsoid.cartographicToCartesian(this.terria.options.defaultResetView),
105+
destination: scene.globe.ellipsoid.cartographicToCartesian(
106+
this.terria.options.defaultResetView
107+
),
88108
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+
) {
92115
try {
93-
Rectangle.validate(this.terria.options.defaultResetView)
116+
Rectangle.validate(this.terria.options.defaultResetView);
94117
camera.flyTo({
95118
destination: this.terria.options.defaultResetView,
96119
orientation,
97-
duration
98-
})
120+
duration,
121+
complete: this.resetSuccess,
122+
});
99123
} 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+
);
101127
}
102128
}
103-
} else if (typeof camera.flyHome === 'function') {
104-
camera.flyHome(1)
129+
} else if (typeof camera.flyHome === "function") {
130+
camera.flyHome(1);
105131
} else {
106-
camera.flyTo({ destination: Camera.DEFAULT_VIEW_RECTANGLE, duration })
132+
camera.flyTo({ destination: Camera.DEFAULT_VIEW_RECTANGLE, duration });
107133
}
108134
}
109-
this.isActive = false
110-
}
135+
this.isActive = false;
136+
};
111137

112138
/**
113139
* When implemented in a derived class, performs an action when the user clicks
@@ -116,7 +142,7 @@ ResetViewNavigationControl.prototype.resetView = function () {
116142
* @protected
117143
*/
118144
ResetViewNavigationControl.prototype.activate = function () {
119-
this.resetView()
120-
}
145+
this.resetView();
146+
};
121147

122-
export default ResetViewNavigationControl
148+
export default ResetViewNavigationControl;

public/CesiumNavigation.umd.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)