前言
cesium 官网的api文档介绍地址cesium官网api,里面详细的介绍 cesium 各个类的介绍,还有就是在线例子:cesium 官网在线例子,这个也是学习 cesium 的好素材。
简单描述Viewer
Viewer 类是 cesium 的核心类,是地图可视化展示的主窗口,cesium 程序应用的切入口,扮演必不可少的核心角色。
官网的英文解析如下:
A base widget for building applications. It composites all of the standard Cesium widgets into one reusable package. The widget can always be extended by using mixins, which add functionality useful for a variety of applications
Viewer对象创建以及参数解析
new Cesium.Viewer(container, options);
container 参数类型 type:Element |String
描述(一般是地图主窗口 div 的 ID):The DOM element or ID that will contain the widget
options 对象,里面属性值特别多,详细的参数见:http://cesiumjs.org/refdoc.html;
个人觉的 Viewer 类 options 参数常用的属性值,其他的用默认值即可:
this.cesiumViewer = new Cesium.Viewer(divId, {
animation:false, //动画控制,默认true
baseLayerPicker:true,//地图切换控件(底图以及地形图)是否显示,默认显示true
fullscreenButton:true,//全屏按钮,默认显示true
geocoder:false,//地名查找,默认true
timeline:false,//时间线,默认true
vrButton:true,//双屏模式,默认不显示false
homeButton:true,//主页按钮,默认true
infoBox:false,//点击要素之后显示的信息,默认true
selectionIndicator:true,//选中元素显示,默认true
imageryProviderViewModels:this._getImageryViewModels(options.mapInitParams.imageryViewModels),//设置影像图列表
terrainProviderViewModels:this._getTerrainViewModels(options.mapInitParams.terrainViewModels)//设置地形图列表
});
-
animation, 是否显示动画效果控件,默认 true ;设置 false,动画效果控件不可见
image -
timeline, 是否显示时间轴控件,默认true;设置 false,时间轴控件不可见
image -
baseLayerPicker, 是否显示底图切换控件,默认 true
image设置 false
更多的详情见:GIS之家小专栏
文章尾部提供源代码下载,对本专栏感兴趣的话,可以关注一波