Skip to main content

Cesium 初始化Viewer基本配置参数说明-2

设置初始化范围

//Rectangle(west, south, east, north)
    //设置初始化中国范围
    Cesium.Camera.DEFAULT_VIEW_RECTANGLE =
                Cesium.Rectangle.fromDegrees(...[100, 10, 120, 70]);

初始化配置参数说明

      animation: false, //是否创建动画小器件,左下角仪表
      baseLayerPicker: false, //是否显示图层选择器
      fullscreenButton: false, //是否显示全屏按钮
      geocoder: false, //是否显示geocoder小器件,右上角查询按钮
      homeButton: false, //是否显示Home按钮
      infoBox: false, //是否显示信息框
      sceneModePicker: false, //是否显示3D/2D选择器
      selectionIndicator: false, //是否显示选取指示器组件
      timeline: false, //是否显示时间轴
      sceneMode: Cesium.SceneMode.SCENE3D, //设定3维地图的默认场景模式:Cesium.SceneMode.SCENE2D、Cesium.SceneMode.SCENE3D、Cesium.SceneMode.MORPHING
      navigationHelpButton: false, //是否显示右上角的帮助按钮
      scene3DOnly: true, //如果设置为true,则所有几何图形以3D模式绘制以节约GPU资源
      navigationInstructionsInitiallyVisible: false,
      showRenderLoopErrors: false //是否显示渲染错误
      //设置背景透明
      orderIndependentTranslucency:false
      contextOptions:{
        webgl:{
          alpha:true
        }
      }

隐藏logo

//方式一 
this.viewer._cesiumWidget._creditContainer.style.display = "none";
//方式二 css
.cesium-widget-credits {
  display: none !important;
  visibility: hide !important;
}

自定义logo

 var mapDom = document.getElementById("cesiumContainer"); 
 var viewportQuad = new Cesium.ViewportQuad();
 viewportQuad.rectangle = new Cesium.BoundingRectangle(
        mapDom.clientWidth - 85,
        5,
        80,
        80
      );
 this.viewer.scene.primitives.add(viewportQuad);

 viewportQuad.material = new Cesium.Material({
        fabric: {
          type: "Image",
          uniforms: {
            color: new Cesium.Color(1.0, 1.0, 1.0, 1.0),
            image: "图片路径"
          }
        }
      });
    }

发表回复