| | |
| | | const configTool = { |
| | | time: 5, |
| | | setMapFly(res) { |
| | | var that = this; |
| | | const alt = res.alt == 0 ? 100 : res.alt; |
| | | //设置初始视图位置 |
| | | Viewer.camera.flyTo({ |
| | | // fromDegrees()方法,将经纬度和高程转换为世界坐标 |
| | | destination: Cesium.Cartesian3.fromDegrees(res.lon, res.lat, alt), |
| | | orientation: { |
| | | // 方向 |
| | | heading: res.heading, |
| | | // 视角 |
| | | pitch: res.pitch, |
| | | // 倾斜角度 |
| | | roll: res.roll, |
| | | // 设置飞行持续时间,默认会根据距离来计算 |
| | | duration: that.time, |
| | | }, |
| | | }); |
| | | }, |
| | | getNewDateTime() { |
| | | return new Date().getTime(); |
| | | }, |
| | | getEndDateTime() { |
| | | return this.getNewDateTime() + 3600 * 2; |
| | | }, |
| | | //点击获取经纬度 |
| | | getViewerPosition(res) { |
| | | const cartesain = Viewer.camera.pickEllipsoid(res.position); |
| | | var cartographic = Cesium.Cartographic.fromCartesian(cartesain); |
| | | return { |
| | | lon: parseFloat(Cesium.Math.toDegrees(cartographic.longitude)).toFixed(6), |
| | | lat: parseFloat(Cesium.Math.toDegrees(cartographic.latitude)).toFixed(6), |
| | | alt: cartographic.height, |
| | | heading: Viewer.scene.camera.heading, |
| | | pitch: Viewer.scene.camera.pitch, |
| | | roll: Viewer.scene.camera.roll, |
| | | }; |
| | | }, |
| | | //获取当前视角信息 |
| | | getViewerCamera() { |
| | | var position = Viewer.scene.camera.positionCartographic; |
| | | return { |
| | | lon: Cesium.Math.toDegrees(position.longitude).toFixed(6), |
| | | lat: Cesium.Math.toDegrees(position.latitude).toFixed(6), |
| | | alt: position.height, |
| | | heading: Viewer.scene.camera.heading, |
| | | pitch: Viewer.scene.camera.pitch, |
| | | roll: Viewer.scene.camera.roll, |
| | | }; |
| | | }, |
| | | getTreeDataCheck(res, std) { |
| | | for (var i in res) { |
| | | if (res[i].children) { |
| | | this.getTreeDataCheck(res[i].children, std); |
| | | } else { |
| | | if (res[i].checked) { |
| | | std.push(res[i].id); |
| | | } |
| | | } |
| | | } |
| | | return std; |
| | | }, |
| | | }; |
| | | export default configTool; |
| | | const configTool = {
|
| | | time: 5,
|
| | | setMapFly(res) {
|
| | | var that = this;
|
| | | const alt = res.alt == 0 ? 100 : res.alt;
|
| | | //设置初始视图位置
|
| | | Viewer.camera.flyTo({
|
| | | // fromDegrees()方法,将经纬度和高程转换为世界坐标
|
| | | destination: Cesium.Cartesian3.fromDegrees(res.lon, res.lat, alt),
|
| | | orientation: {
|
| | | // 方向
|
| | | heading: res.heading,
|
| | | // 视角
|
| | | pitch: res.pitch,
|
| | | // 倾斜角度
|
| | | roll: res.roll,
|
| | | // 设置飞行持续时间,默认会根据距离来计算
|
| | | duration: that.time
|
| | | }
|
| | | });
|
| | | },
|
| | | getNewDateTime() {
|
| | | return new Date().getTime();
|
| | | },
|
| | | getEndDateTime() {
|
| | | return this.getNewDateTime() + 3600 * 2;
|
| | | },
|
| | | //点击获取经纬度
|
| | | getViewerPosition(res) {
|
| | | const cartesain = Viewer.camera.pickEllipsoid(res.position);
|
| | | var cartographic = Cesium.Cartographic.fromCartesian(cartesain);
|
| | | return {
|
| | | lon: parseFloat(Cesium.Math.toDegrees(cartographic.longitude)).toFixed(6),
|
| | | lat: parseFloat(Cesium.Math.toDegrees(cartographic.latitude)).toFixed(6),
|
| | | alt: cartographic.height,
|
| | | heading: Viewer.scene.camera.heading,
|
| | | pitch: Viewer.scene.camera.pitch,
|
| | | roll: Viewer.scene.camera.roll
|
| | | };
|
| | | },
|
| | | //获取当前视角信息
|
| | | getViewerCamera() {
|
| | | var position = Viewer.scene.camera.positionCartographic;
|
| | | return {
|
| | | lon: Cesium.Math.toDegrees(position.longitude).toFixed(6),
|
| | | lat: Cesium.Math.toDegrees(position.latitude).toFixed(6),
|
| | | alt: position.height.toFixed(6),
|
| | | heading: Cesium.Math.toDegrees(Viewer.scene.camera.heading),
|
| | | pitch: Cesium.Math.toDegrees(Viewer.scene.camera.pitch),
|
| | | roll: Cesium.Math.toDegrees(Viewer.scene.camera.roll)
|
| | | };
|
| | | },
|
| | | getTreeDataCheck(res, std) {
|
| | | for (var i in res) {
|
| | | if (res[i].children) {
|
| | | this.getTreeDataCheck(res[i].children, std);
|
| | | } else {
|
| | | if (res[i].checked) {
|
| | | std.push(res[i].id);
|
| | | }
|
| | | }
|
| | | }
|
| | | return std;
|
| | | },
|
| | | generateID() {
|
| | | return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
|
| | | /[xy]/g,
|
| | | function (c) {
|
| | | var r = (Math.random() * 16) | 0,
|
| | | v = c === "x" ? r : (r & 0x3) | 0x8;
|
| | | return v.toString(16);
|
| | | }
|
| | | );
|
| | | },
|
| | | saveToJson(data, res) {
|
| | | let content = JSON.stringify(data);
|
| | | let blob = new Blob([content], { type: "" });
|
| | | var reader = new FileReader();
|
| | | reader.onloadend = () => {
|
| | | let url = reader.result;
|
| | | let triggerDownload = document.createElement("a");
|
| | | triggerDownload.download = (res) + ".json";
|
| | | triggerDownload.href = url;
|
| | | triggerDownload.click();
|
| | | };
|
| | | reader.readAsDataURL(blob);
|
| | | }
|
| | | };
|
| | | export default configTool;
|