/////////////////////////////////////////////////////////////////////////// // Copyright © 2020 zhongsong. All Rights Reserved. // 模块描述:飞行路线 /////////////////////////////////////////////////////////////////////////// define(['dojo/_base/declare', 'dojo/_base/lang', 'dojo/_base/array', 'dojo/_base/html', 'dojo/topic', 'jimu/BaseWidget'], function (declare, lang, array, html, topic, BaseWidget) { return declare([BaseWidget], { baseClass: 'jimu-widget-SuperMapFlyRoute', name: 'SuperMapFlyRoute', flightTool: null, allRoutes: null, scene:null, startup: function startup() { var self = this; var viewer = self.map; self.scene = viewer.scene; self.scene.shadowMap.darkness = 1.275; //设置第二重烘焙纹理的效果(明暗程度) self.scene.skyAtmosphere.brightnessShift = 0.4; //修改大气的亮度 self.scene.debugShowFramesPerSecond = true; self.scene.hdrEnabled = false; self.scene.sun.show = false; // 01设置环境光的强度-新处理CBD场景 self.scene.lightSource.ambientLightColor = new Cesium.Color(0.65, 0.65, 0.65, 1); // 添加光源 var position1 = new Cesium.Cartesian3.fromDegrees(116.261209157595, 39.3042238956531, 480); //光源方向点 var targetPosition1 = new Cesium.Cartesian3.fromDegrees(116.261209157595, 39.3042238956531, 430); var dirLightOptions = { targetPosition: targetPosition1, color: new Cesium.Color(1.0, 1.0, 1.0, 1), intensity: 0.55 }; directionalLight_1 = new Cesium.DirectionalLight(position1, dirLightOptions); self.scene.addLightSource(directionalLight_1); self.scene.globe.depthTestAgainstTerrain = false; $('#stopListLX').change(function () { //注册路线切换事件 self.map.entities.removeAll(); self.flyStart($(this).val()); }); $(".super-head-th-xx").click(function () { self.onClose(); $(".jimu-widget-SuperMapFlyRoute").hide(); }); }, getData: function (){ var self = this; //添加fpf飞行文件,fpf由SuperMap iDesktop生成 $.ajax({ url: './widgets/SuperMapFlyRoute/datas.json', type: "POST", dataType: "json", success: function success(data) { var menuLX = document.getElementById('stopListLX'); menuLX.innerHTML = ""; for (var i = 0; i < data.length; i++) { var option = document.createElement('option'); option.innerHTML = data[i].name; option.value = data[i].url; menuLX.appendChild(option); } self.flyStart(data[0].url); } }); }, flyStart: function (url) { var self = this; var routes = new Cesium.RouteCollection(viewer.entities); routes.fromFile(url); //初始化飞行管理 var flyManager = new Cesium.FlyManager({ scene: self.scene, routes: routes }); //注册站点到达事件 flyManager.stopArrived.addEventListener(function (routeStop) { routeStop.waitTime = 1; // 在每个站点处停留1s }); flyManager.readyPromise.then(function () { // 飞行路线就绪 var currentRoute = flyManager.currentRoute; currentRoute.isLineVisible = false; currentRoute.isStopVisible = false; //生成飞行文件中的所有站点列表 var allStops = flyManager.getAllRouteStops(); var menu = document.getElementById('stopList'); menu.innerHTML = ""; for (var i = 0, j = allStops.length; i < j; i++) { var option = document.createElement('option'); option.innerHTML = "站点 " + (i + 1); option.value = allStops[i].index; menu.appendChild(option); } $('#stopList').change(function () { //注册站点切换事件 flyManager && flyManager.stop(); var index = parseInt($(this).val()); // 站点的索引 var route = flyManager.currentRoute; var stop = route.get(index); flyManager.currentStopIndex = index; flyManager.viewToStop(stop); }); $('#play').click(function () { flyManager && flyManager.play(); }); $('#pause').click(function () { flyManager && flyManager.pause(); }); $('#stop').click(function () { flyManager && flyManager.stop(); }); $('#show-line').change(function () { currentRoute.isLineVisible = $(this).prop('checked'); }); $('#show-stop').change(function () { currentRoute.isStopVisible = $(this).prop('checked'); }); $('#toolbar').show(); $('#loadingbar').remove(); $(".cesium-performanceDisplay").hide(); }); }, onMinimize: function () { this.resize(); }, onMaximize: function () { this.resize(); }, resize: function () { }, onOpen: function onOpen() { //面板打开的时候触发 (when open this panel trigger) var self = this; self.getData(); }, onClose: function onClose() { //面板关闭的时候触发 (when this panel is closed trigger) this.map.entities.removeAll(); }, destroy: function destroy() { //销毁的时候触发 //todo //do something before this func this.inherited(arguments); } }); });