liuyg
2021-07-02 25ce610f6ecca7325e7a743dc032c4a76559c63d
widgets/slope/Widget.js
@@ -24,15 +24,15 @@
            },
            beginSlope: function () {
                console.log('beginSlope');
                // 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.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: {
@@ -41,66 +41,25 @@
                //         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(80, new Cesium.Color(255 / 255, 0 / 255, 0 / 255));
                colorTable.insert(50, new Cesium.Color(221 / 255, 224 / 255, 7 / 255));
                colorTable.insert(30, new Cesium.Color(20 / 255, 187 / 255, 18 / 255));
                colorTable.insert(20, new Cesium.Color(0, 161 / 255, 1));
                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 = 0.5;
                slope.Opacity = 1;
                function createTooltip(frameDiv) {//创建需要的函数
                    var tooltip = function (frameDiv) {
                        var div = document.createElement('DIV');
                        div.className = "twipsy right";
                        var arrow = document.createElement('DIV');
                        arrow.className = "twipsy-arrow";
                        div.appendChild(arrow);
                        var title = document.createElement('DIV');
                        title.className = "twipsy-inner";
                        div.appendChild(title);
                        this._div = div;
                        this._title = title;
                        this.message = '';
                        // add to frame div and display coordinates
                        frameDiv.appendChild(div);
                        var that = this;
                        div.onmousemove = function (evt) {
                            that.showAt({ x: evt.clientX, y: evt.clientY }, that.message);
                        };
                    };
                    tooltip.prototype.setVisible = function (visible) {
                        this._div.style.display = visible ? 'block' : 'none';
                    };
                    tooltip.prototype.showAt = function (position, message) {
                        if (position && message) {
                            this.setVisible(true);
                            this._title.innerHTML = message;
                            this._div.style.left = position.x + 10 + "px";
                            this._div.style.top = (position.y - this._div.clientHeight / 2) + "px";
                            this.message = message;
                        }
                    };
                    return new tooltip(frameDiv);
                }
                var tooltip = createTooltip(viewer._element);
                var tooltip = window.MYcreateTooltip(viewer._element);
                //绘制多边形
                var handlerPolygon = new Cesium.DrawHandler(viewer, Cesium.DrawMode.Polygon, 0);
                handlerPolygon.activeEvt.addEventListener(function (isActive) {
@@ -154,12 +113,18 @@
                });
                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 () {
@@ -233,13 +198,13 @@
                    };
                }
                )
                $("#colorTable1").on("input change", function () {
                $("#colorTable12").on("input change", function () {
                    colorTable.remove(0);
                    colorTable.remove(20);
                    colorTable.remove(30);
                    colorTable.remove(50);
                    colorTable.remove(80);
                    var value = document.getElementById("colorTable1").selectedIndex;
                    var value = document.getElementById("colorTable12").selectedIndex;
                    switch (value) {
                        case 0:
                            colorTable.insert(0, new Cesium.Color(9 / 255, 9 / 255, 255 / 255));
@@ -292,6 +257,26 @@
                $('#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 () {