Cesium之Viewer初始常用配置
目录
常用配置
- 左下角控制动画
- 右上角底图切换选择器
- 全屏
- 搜索
- 缩放到全图
- 信息框
- 2、2.5、3维切换
- 选中状态(绿框)
- 时间轴
- 帮助提示按钮
- 导航指令
- 投影选择器
- 地形图层
- 影像图
- 地形高度
- 取消双击事件
- 隐藏cesium icon
- 隐藏infobox camera
- infobox支持js调用
代码
viewer = new Cesium.Viewer("cesiumContainer", {
shadows: false, //阴影
animation: false, //左下角控制动画
baseLayerPicker: false, //右上角图层选择器
fullscreenButton: false,//全屏
geocoder: false, //右上角搜索
homeButton: false,// 主页
infoBox: true,// 信息框
scene3DOnly: true, //仅仅显示3d,可隐藏右上角2d和3d按钮
selectionoIndicator: false,// 绿色选择框
timeline: false, //最下面时间轴
navigationHelpButton: true, //右上角帮助按钮
navigationInstructionsInitiallyVisible: true, //导航指令
useDefaultRenderLoop: true,
showRenderLoopErrors: true,
projectionPicker: false, //投影选择器
terrainProvider: Cesium.createWorldTerrain(),// 地形
imageryProvider: google, //影像图
});
viewer.scene.globe.depthTestAgainstTerrain = true; //地形高度
//取消双击事件
viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
viewer._cesiumWidget._creditContainer.style.display = "none"; // 隐藏cesium icon
document.querySelector('.cesium-infoBox-camera').style.display = 'none';//隐藏infobox camera
infobox支持js方法调用
//infobox支持js方法调用
function supportJSForInfoBox() {
let iframe = document.getElementsByClassName('cesium-infoBox-iframe')[0];
iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts allow-popups allow-forms');
iframe.setAttribute('src', '');
}