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-slope', name: 'slope', flag: false, startup: function () { var that = this; topic.subscribe("getbeginSlope", lang.hitch(this, this.beginSlope)); // topic.publish('getbeginSlope', that.beginSlope); }, beginSlope: function () { // console.log('beginSlope'); var that = this; var viewer = that.map; var scene = viewer.scene; scene.globe.enableLighting = true; //添加SuperMap iServer发布的影像服务 // viewer.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({ // url: 'http://www.supermapol.com/realspace/services/3D-ZF_normal/rest/realspace/datas/image' // })); // viewer.scene.camera.setView({ // destination: Cesium.Cartesian3.fromDegrees(87.1, 27.8, 8000.0), // orientation: { // heading: 6.10547067016156, // pitch: -0.8475077031996778, // roll: 6.2831853016686185 // } // }); viewer.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({ url: 'http://www.supermapol.com/realspace/services/3D-ZF_normal/rest/realspace/datas/image' })); var slope = new Cesium.SlopeSetting(); slope.DisplayMode = Cesium.SlopeSettingEnum.DisplayMode.FACE_AND_ARROW; slope.MaxVisibleValue = document.getElementById("widemax").value; slope.MinVisibleValue = document.getElementById("widemin").value; var colorTable = new Cesium.ColorTable(); colorTable.insert(8000, new Cesium.Color(255 / 255, 0 / 255, 0 / 255)); colorTable.insert(5000, new Cesium.Color(221 / 255, 224 / 255, 7 / 255)); colorTable.insert(3000, new Cesium.Color(20 / 255, 187 / 255, 18 / 255)); colorTable.insert(2000, new Cesium.Color(0, 161 / 255, 1)); colorTable.insert(0, new Cesium.Color(9 / 255, 9 / 255, 255 / 255)); var wide; wide = Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_REGION; slope.ColorTable = colorTable; slope.Opacity = 1; var tooltip = window.MYcreateTooltip(viewer._element); //绘制多边形 var handlerPolygon = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Polygon, 0); handlerPolygon.activeEvt.addEventListener(function (isActive) { if (isActive == true) { viewer.enableCursorStyle = false; viewer._element.style.cursor = ''; $('body').removeClass('drawCur').addClass('drawCur'); } else { viewer.enableCursorStyle = true; $('body').removeClass('drawCur'); } }); handlerPolygon.movingEvt.addEventListener(function (windowPosition) { if (windowPosition.x < 200 && windowPosition.y < 150) { tooltip.setVisible(false); return; } }); handlerPolygon.drawEvt.addEventListener(function (result) { if (!result.object.positions) { handlerPolygon.polygon.show = false; handlerPolygon.polyline.show = false; handlerPolygon.deactivate(); handlerPolygon.activate(); return; } var array = [].concat(result.object.positions); tooltip.setVisible(false); var positions = []; for (var i = 0, len = array.length; i < len; i++) { var cartographic = Cesium.Cartographic.fromCartesian(array[i]); var longitude = Cesium.Math.toDegrees(cartographic.longitude); var latitude = Cesium.Math.toDegrees(cartographic.latitude); var h = cartographic.height; if (positions.indexOf(longitude) == -1 && positions.indexOf(latitude) == -1) { positions.push(longitude); positions.push(latitude); positions.push(h); } } slope.CoverageArea = positions; viewer.scene.globe.SlopeSetting = { slopeSetting: slope, analysisMode: wide }; handlerPolygon.polygon.show = false; handlerPolygon.polyline.show = true; handlerPolygon.deactivate(); handlerPolygon.activate(); }); handlerPolygon.activate(); document.getElementById("cance").onclick = function () { // console.log('cance') viewer.scene.globe.SlopeSetting = { slopeSetting: slope, analysisMode: Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_NONE }; handlerPolygon.polygon.show = false; handlerPolygon.polyline.show = false; scene.globe.enableLighting = false; //关闭该绘画图层 // handlerPolygon.clear(); }; viewer._cesiumWidget._creditContainer.style.display = "none"; $("#split").on("click", function () { $("#float").slideToggle(500); } ); $("#trans").on("input change", function () { slope.Opacity = this.value; viewer.scene.globe.SlopeSetting = { slopeSetting: slope, analysisMode: wide }; }); $("#wideminR").on("input change", function () { var a = document.getElementById("widemin"); a.value = this.value; slope.MinVisibleValue = this.value; viewer.scene.globe.SlopeSetting = { slopeSetting: slope, analysisMode: wide }; }); $("#widemin").on("input change", function () { var a = document.getElementById("widemin"); a.value = this.value; }); $("#widemaxR").on("input change", function () { var a = document.getElementById("widemax"); a.value = this.value; slope.MaxVisibleValue = this.value; viewer.scene.globe.SlopeSetting = { slopeSetting: slope, analysisMode: wide }; }); $("#widemax").on("input change", function () { var a = document.getElementById("widemaxR"); a.value = this.value; }); $("#calMode").on("input change", function () { var index = document.getElementById("calMode").selectedIndex; switch (index) { case 0: wide = Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_REGION; break; case 1: wide = Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_ALL; break; case 2: wide = Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_NONE; break; default: break; } viewer.scene.globe.SlopeSetting = { slopeSetting: slope, analysisMode: wide }; }); $(":radio[name='fill']").change(function () { if (document.getElementById("showcolor").checked) { slope.DisplayMode = Cesium.SlopeSettingEnum.DisplayMode.FACE; } else if (document.getElementById("showarrow").checked) { slope.DisplayMode = Cesium.SlopeSettingEnum.DisplayMode.ARROW; } else { slope.DisplayMode = Cesium.SlopeSettingEnum.DisplayMode.FACE_AND_ARROW; } viewer.scene.globe.SlopeSetting = { slopeSetting: slope, analysisMode: wide }; } ) $("#colorTable12").on("input change", function () { colorTable.remove(0); colorTable.remove(20); colorTable.remove(30); colorTable.remove(50); colorTable.remove(80); var value = document.getElementById("colorTable12").selectedIndex; switch (value) { case 0: colorTable.insert(0, new Cesium.Color(9 / 255, 9 / 255, 255 / 255)); colorTable.insert(20, new Cesium.Color(0, 161 / 255, 1)); colorTable.insert(30, new Cesium.Color(20 / 255, 187 / 255, 18 / 255)); colorTable.insert(50, new Cesium.Color(221 / 255, 224 / 255, 7 / 255)); colorTable.insert(80, new Cesium.Color(255 / 255, 0 / 255, 0 / 255)); break; case 1: colorTable.insert(0, new Cesium.Color(162 / 255, 251 / 255, 194 / 255)); colorTable.insert(20, new Cesium.Color(180 / 255, 200 / 255, 170 / 255)); colorTable.insert(30, new Cesium.Color(200 / 255, 160 / 255, 130 / 255)); colorTable.insert(50, new Cesium.Color(225 / 255, 130 / 255, 130 / 255)); colorTable.insert(80, new Cesium.Color(1, 103 / 255, 103 / 255)); break; case 2: colorTable.insert(0, new Cesium.Color(230 / 255, 198 / 255, 1)); colorTable.insert(20, new Cesium.Color(210 / 255, 150 / 255, 1)); colorTable.insert(30, new Cesium.Color(190 / 255, 100 / 255, 1)); colorTable.insert(50, new Cesium.Color(165, 50 / 255, 1)); colorTable.insert(80, new Cesium.Color(157 / 255, 0, 1)); break; case 3: colorTable.insert(0, new Cesium.Color(0, 39 / 255, 148 / 255)); colorTable.insert(20, new Cesium.Color(0, 39 / 255, 148 / 255)); colorTable.insert(30, new Cesium.Color(70 / 255, 116 / 255, 200 / 255)); colorTable.insert(50, new Cesium.Color(149 / 255, 232 / 255, 249 / 255)); colorTable.insert(80, new Cesium.Color(149 / 255, 232 / 255, 249 / 255)); break; case 4: colorTable.insert(0, new Cesium.Color(186 / 255, 1, 190 / 255)); colorTable.insert(20, new Cesium.Color(186 / 255, 1, 180 / 255)); colorTable.insert(30, new Cesium.Color(106 / 255, 255 / 255, 170 / 255)); colorTable.insert(50, new Cesium.Color(26 / 255, 255 / 255, 160 / 255)); colorTable.insert(80, new Cesium.Color(26 / 255, 255 / 255, 156 / 255)); break; default: break; } slope.ColorTable = colorTable; viewer.scene.globe.SlopeSetting = { slopeSetting: slope, analysisMode: wide }; }); if (!scene.pickPositionSupported) { alert('不支持深度纹理,无法绘制多边形,根据多边形显示分析区域功能无法使用!'); } $('#toolbar').show(); $('#btnContainer').show(); $('#loadingbar').remove(); that.handlerPolygon = handlerPolygon; that.viewer = viewer; that.scene = scene; that.slope = slope; topic.subscribe("closes", lang.hitch(this, this.closes)); }, handlerPolygon: '', viewer: '', scene: '', closes: function () { // 关闭绘画层 this.viewer.scene.globe.SlopeSetting = { slopeSetting: this.slope, analysisMode: Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_NONE }; // handlerPolygon.polygon.show = false; // handlerPolygon.polyline.show = false; this.scene.globe.enableLighting = false; this.handlerPolygon.clear(); }, onOpen: function () { }, onClose: function () { //面板关闭的时候触发 (when this panel is closed trigger) console.log('jies') }, onMinimize: function () { this.resize(); }, onMaximize: function () { this.resize(); }, resize: function () { }, destroy: function () { //销毁的时候触发 //todo //do something before this func this.inherited(arguments); } }); });