首页 / 浏览问题 / 三维GIS / 问题详情
HypsometricSetting 设置 CoverageArea 参数无效
13EXP 2020年12月23日

http://support.supermap.com.cn:8090/webgl/examples/webgl/editor.html#STKterrain

如题

//创建分层设色对象
            var hyp = new Cesium.HypsometricSetting();
            //设置分层设色的显示模式为线
            hyp.DisplayMode = Cesium.HypsometricSettingEnum.DisplayMode.LINE;
            //设置线颜色为红色
            hyp._lineColor = new Cesium.Color(1.0, 0.0, 0.0, 1.0);
            //等高线间隔为100m
            hyp.LineInterval = 100.0;
            //设置分层设色的最大/最小可见高度
            hyp.MaxVisibleValue = 9000;
            hyp.MinVisibleValue = 0;
            hyp.CoverageArea = [];
            //设置分层设色颜色表的最大/最小key值,表示在此高度范围内显示颜色表
            hyp.ColorTableMinKey = 2736.88110351563;
            hyp.ColorTableMaxKey = 5597.06640625;
            //新建颜色表
            var colorTable = new Cesium.ColorTable();
            
            colorTable.insert(5597.06640625,new Cesium.Color(0, 0, 255/255));
            colorTable.insert(5406.3873860677086,new Cesium.Color(0, 51/255, 255/255));
            colorTable.insert(5215.7083658854172,new Cesium.Color(0, 102/255, 255/255));
            colorTable.insert(5025.0293457031257,new Cesium.Color(0, 153/255, 255/255));
            colorTable.insert(4834.3503255208343,new Cesium.Color(0, 204/255, 255/255));
            colorTable.insert(4643.6713053385429,new Cesium.Color(0, 255/255, 255/255));
            colorTable.insert(4452.9922851562524,new Cesium.Color(51/255, 255/255, 204/255));
            colorTable.insert(4262.3132649739609,new Cesium.Color(102/255, 255/255, 153/255));
            colorTable.insert(4071.6342447916695,new Cesium.Color(153/255, 255/255, 102/255));
            colorTable.insert(3880.9552246093781,new Cesium.Color(204/255, 255/255, 51/255));
            colorTable.insert(3690.2762044270867,new Cesium.Color(255/255, 255/255, 0));
            colorTable.insert(3499.5971842447952,new Cesium.Color(255/255, 204/255, 0));
            colorTable.insert(3308.9181640625038,new Cesium.Color(255/255, 153/255, 0));
            colorTable.insert(3118.2391438802129,new Cesium.Color(255/255, 102/255, 0));
            colorTable.insert(2927.5601236979214,new Cesium.Color(255/255, 51/255, 0));
            colorTable.insert(2736.88110351563,new Cesium.Color(255/255, 0, 0));
            
            //设置分层设色的颜色表
            hyp.ColorTable = colorTable;
            //设置分层设色的透明度
            hyp.Opacity = 0.4;

        
        var tooltip = createTooltip(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);
                }
            }

            hyp.CoverageArea = positions;
            // viewer.scene.globe.SlopeSetting = {
            //     slopeSetting: slope,
            //     analysisMode: wide
            // };
            hyp.DisplayMode = Cesium.HypsometricSettingEnum.DisplayMode.FACE_AND_LINE;
                viewer.scene.globe.HypsometricSetting = {
                    hypsometricSetting : hyp,
                    analysisMode : Cesium.HypsometricSettingEnum.AnalysisRegionMode.ARM_ALL
                };
            handlerPolygon.polygon.show = false;
            handlerPolygon.polyline.show = true;
            handlerPolygon.deactivate();
            handlerPolygon.activate();
        });
        handlerPolygon.activate();

问题关闭原因: analysisMode
...