在开发本身的项目时,有时候须要对界面作必定的定制,这就须要隐藏一部分界面中的元素,下面咱们来看看各个元素的描述css
首先建立一个空的工程来测试,源码在https://gitee.com/HQCode/Cesium-testhtml
界面上默认的小控件能够经过在初始化Viewer的时候设置相应的属性来关闭,一下列出了界面默认的小控件的关闭方法,还有不少额外的属性,能够查看 帮助文档git
<div id="credit"></div> var viewer = new Cesium.Viewer('cesiumContainer',{ geocoder:false, homeButton:false, sceneModePicker:false, baseLayerPicker:false, navigationHelpButton:false, animation:false, creditContainer:"credit", timeline:false, fullscreenButton:false, vrButton:false, // skyBox : new Cesium.SkyBox({ // sources : { // positiveX : 'stars/TychoSkymapII.t3_08192x04096_80_px.jpg', // negativeX : 'stars/TychoSkymapII.t3_08192x04096_80_mx.jpg', // positiveY : 'stars/TychoSkymapII.t3_08192x04096_80_py.jpg', // negativeY : 'stars/TychoSkymapII.t3_08192x04096_80_my.jpg', // positiveZ : 'stars/TychoSkymapII.t3_08192x04096_80_pz.jpg', // negativeZ : 'stars/TychoSkymapII.t3_08192x04096_80_mz.jpg' // } // }) });
相关代码lesson01-index.htmlless
若是控件已经建立了,也能够这样:工具
var viewer = new Cesium.Viewer('cesiumContainer'); viewer.animation.container.style.display = "none"; viewer.baseLayerPicker.container.style.display = "none"; //版权清理 viewer.cesiumWidget.creditContainer.style.display = "none"; viewer.bottomContainer.style.display = "none";
/* 不占据空间,没法点击 */ .cesium-viewer-toolbar, /* 右上角按钮组 */ .cesium-viewer-animationContainer, /* 左下角动画控件 */ .cesium-viewer-timelineContainer, /* 时间线 */ .cesium-viewer-bottom /* logo信息 */ { display: none; } .cesium-viewer-fullscreenContainer /* 全屏按钮 */ { position: absolute; top: -999em; }
注:全屏按钮不能经过display:none的方式来达到隐藏的目的,这是由于生成的按钮控件的行内样式设置了display属性,会覆盖引入的css属性测试
<div class="cesium-viewer-fullscreenContainer" style="display: block;">...</div>
相关代码lesson01-index02.html动画
viewer.scene.debugShowFramesPerSecond = true;