bcgis-type
Version:
The SDK is based on Cesium for secondary development of 2, 3D all-in-one WebGis application framework, the framework optimizes the use of Cesium and add some additional features, designed for developers to quickly build WebGis applications.
451 lines (450 loc) • 12.7 kB
TypeScript
import Tooltip from "../widget/type/Tooltip";
import { ViewerEvent, MouseEvent } from "../event";
import { MouseMode } from "../option";
import { T_Position } from "../common/type";
import { Compass, ContextMenu, DistanceLegend, LoadingMask, LocationBar, MapSplit, MapSwitch, Popup, SceneSplit, TilesetSplit, ZoomController, HawkeyeMap } from "../exports/widgets";
import LayerGroup from "../layer/LayerGroup";
import { Layer } from "../layer";
/**
* 3D 场景主要接口,在给定的 DivId 中构建三维场景
* @noInheritDoc
* @example
* ```html
* <div id="viewer-container"></div>
* ```
*
* ```ts
* let viewer = BC.Viewer('viewer-container')
* global.viewer = viewer // 添加到全局变量
* ```
*/
declare class Viewer {
private _delegate;
private _viewerEvent;
private _sceneEvent;
private _viewerOption;
private _cameraOption;
private _dcContainer;
private _baseLayerPicker;
private _layerGroupCache;
private _layerCache;
private _mouseEvent;
cesiumWidget: Cesium.CesiumWidget;
tooltip: Tooltip;
compass: Compass;
popup: Popup;
contextMenu: ContextMenu;
mapSwitch: MapSwitch;
mapSplit: MapSplit;
locationBar: LocationBar;
hawkeyeMap: HawkeyeMap;
distanceLegend: DistanceLegend;
zoomController: ZoomController;
loadingMask: LoadingMask;
tilesetSplit: TilesetSplit;
sceneSplit: SceneSplit;
/**
*
* @param id - 容器id
* @param options - 参数
* @example
* ```json
* //属性参数(可选)
* {
* "contextOptions": {
* "webgl": {
* "alpha": false, //背景
* "depth": true,
* "stencil": false,
* "antialias": true,
* "powerPreference": "high-performance",
* "premultipliedAlpha": true,
* "preserveDrawingBuffer": false,
* "failIfMajorPerformanceCaveat": false
* },
* "allowTextureFilterAnisotropic": true
* },
* "sceneMode": 3 //1: 2.5D,2: 2D,3: 3D
* }
* ```
*/
constructor(id: string | HTMLElement, options?: {});
/**
* 获取Cesium原生Viewer
*/
get delegate(): Cesium.Viewer;
/**
* 框架自定义容器
* @readonly
*/
get dcContainer(): any;
/**
* 场景
* @readonly
*/
get scene(): Cesium.Scene;
/**
* 相机
* @readonly
*/
get camera(): Cesium.Camera;
/**
* canvas节点
* @readonly
*/
get canvas(): HTMLCanvasElement;
/**
* viewer数据源
* @readonly
*/
get dataSources(): Cesium.DataSourceCollection;
/**
* 影像类图层组
* @readonly
*/
get imageryLayers(): Cesium.ImageryLayerCollection;
/**
* 地形
* @readonly
*/
get terrainProvider(): Cesium.TerrainProvider;
/**
* 实体集合
* @readonly
*/
get entities(): Cesium.EntityCollection;
/**
* 预处理集合
* @readonly
*/
get postProcessStages(): Cesium.PostProcessStageCollection;
/**
* 时钟
*/
get clock(): Cesium.Clock;
/**
* viewer私有事件
*/
get viewerEvent(): ViewerEvent;
get mouseEvent(): MouseEvent;
/**
* 摄像头位置
*/
get cameraPosition(): import("../position/Position").default;
/**
* 层级
*/
get resolution(): number;
/**
* 当前视角范围
*/
get viewBounds(): Cesium.Rectangle;
/**
* 层级
*/
get level(): any;
/***
* 添加图层组
* @param layerGroup - 图层组
* @private
*/
_addLayerGroup(layerGroup: LayerGroup): void;
/**
*
* @param layerGroup
* @private
*/
private _removeLayerGroup;
/**
* 添加图层
* @param layer - 图层
* @private
*/
private _addLayer;
/**
* 移除图层
* @param layer 图层
* @private
*/
_removeLayer(layer: Layer): void;
/**
* 设置属性
* @param options 属性
* @returns {Viewer}
* @example
* ```json
* // 属性参数(可选)
* {
* "shadows": false, // 是否开启阴影
* "resolutionScale": 1, // 设置渲染分辨率的缩放比例
* "showAtmosphere": true, //是否显示大气层
* "showSun": true, //是否显示太阳
* "showMoon": true, //是否显示月亮
* "enableFxaa": true, //是否开启抗锯齿
* "msaaSamples": 1, //msaa抗拒出取样度
* "cameraController": {
* // 相机控制
* "enableRotate": true, // 是否可以旋转
* "enableTilt": true, // 是否可以翻转
* "enableTranslate": true, // 是否可以平移
* "enableZoom": true, // 是否可以缩放
* "enableCollisionDetection": true, // 是否支持碰撞检测
* "minimumZoomDistance": 1.0, // 最小缩放距离
* "maximumZoomDistance": 40489014.0 // 最大缩放距离
* },
* "globe": {
* "show": true, // 是否显示地球
* "showGroundAtmosphere": true, // 显示地面大气
* "enableLighting": false, //是否开启灯光,开启后地球会根据当前时间启用灯光
* "depthTestAgainstTerrain": false, //是否开启深度检测
* "tileCacheSize": 100, // 默认瓦片缓存大小
* "preloadSiblings": false, //是否应预加载渲染同级图块
* "terrainExaggeration": 1, //地形夸张系数
* "terrainExaggerationRelativeHeight": 1, //地形相对高度夸张系数
* "baseColor": new DC.Color(0, 0, 0.5, 1), //地球默认底色
* "filterColor": new DC.Color(0, 0, 0, 0), //瓦片过滤色
* "translucency": {
* //地表透明
* "enabled": false, // 是否开启地表透明
* "backFaceAlpha": 1, // 地球背面透明度
* "backFaceAlphaByDistance": null, //根据距离设置地球背面透明度: {near:400,nearValue:0.2,far:800,farValue:1}
* "frontFaceAlpha": 1, // 地球正面透明度
* "frontFaceAlphaByDistance": null //根据距离设置地球正面透明度: {near:400,nearValue:0.2,far:800,farValue:1}
* }
* },
* "skyBox": {
* "sources": {}, // 六个面的贴图
* "show": true, //是否显示
* "offsetAngle": 0 //旋转角度
* }
* }
* ```
*/
setOptions(options: any): this;
/**
* 设置翻转角度
* @param min 最小角度
* @param max 最大角度
* @returns {Viewer}
*/
setPitchRange(min?: number, max?: number): this;
/**
* @param west
* @param south
* @param east
* @param north
* @returns {Viewer}
*/
setBounds(west: any, south: any, east: any, north: any): this;
/**
* 改变场景模式,
* @param sceneMode - 场景模式 2:2D,2.5:2.5D,3:3D
* @param duration - 间隔时间
* @returns {Viewer}
*/
changeSceneMode(sceneMode: any, duration?: number): this;
/**
* 改变鼠标使用模式
* @param mouseMode - 鼠标模式
* @returns {Viewer}
*/
changeMouseMode(mouseMode: MouseMode): this;
/**
* 添加基础图层
* @param baseLayers 基础地图图层
* @param options 属性
* @returns {Viewer}
*/
addBaseLayer(baseLayers: Cesium.ImageryProvider | Cesium.TerrainProvider | Array<Cesium.ImageryProvider> | Array<Cesium.TerrainProvider>, options?: any): this;
/**
* 修改基础图层
* @param index 图层索引
* @returns {Viewer}
*/
changeBaseLayer(index: any): this;
/**
*
* @param windowPosition
* @returns {Promise}
*/
getImageryLayerInfo(windowPosition: any): Promise<Cesium.ImageryLayerFeatureInfo[]>;
/**
* 添加地形
* @param terrain 地形图层
* @param options 属性
* @returns {Viewer}
*/
addTerrain(terrain: any, options?: any): this;
/**
* 修改地形
* @param index 图层索引
* @returns {Viewer}
*/
changeTerrain(index: any): this;
/**
* 移除地形
* @returns {Viewer}
*/
removeTerrain(): this;
/**
* 添加图层组
* @param layerGroup 图层组
* @returns {Viewer}
*/
addLayerGroup(layerGroup: LayerGroup): this;
/**
* 移除图层组
* @param layerGroup - 图层组
* @returns {Viewer}
*/
removeLayerGroup(layerGroup: LayerGroup): this;
/**
* 根据id获取图层组
* @param id - 图层组id
* @returns {undefined}
*/
getLayerGroup(id: string): LayerGroup;
/**
* 添加图层
* @param layer
* @returns {Viewer}
*/
addLayer(layer: Layer): this;
/**
* 移除图层
* @param layer 图层
* @returns {Viewer}
*/
removeLayer(layer: Layer): this;
/**
* 检查是否有某个图层
* @param layer
* @returns {boolean}
*/
hasLayer(layer: Layer): boolean;
/**
* 根据id获取图层
* @param id
* @returns {*|undefined}
*/
getLayer(id: string): any;
/**
* 获取全部图层
* @returns {[]}
*/
getLayers(): any[];
/**
* 遍历所有图层
* @param method 回调函数
* @param context 上下文
* @returns {Viewer}
*/
eachLayer(method: Function, context: any): this;
/**
* 根据图层属性获取图层
* @param attrName 属性名称
* @param attrVal 属性值
* @returns 图层数组
*/
getLayersByAttr(attrName: string, attrVal: any): Layer[];
/**
* 飞行到
* @param target - 目标
* @param duration -飞到位置的时间(s)
* @returns {Viewer}
*/
flyTo(target: any, duration?: number): this;
/**
* 缩放到
* @param target 目标
* @returns {Viewer}
*/
zoomTo(target: any): this;
/**
* 飞到具体位置
* @param position 坐标
* @param completeCallback 回调函数
* @param duration 间隔时间
* @returns {Viewer}
*/
flyToPosition(position: T_Position, completeCallback: any, duration: any): this;
/**
* 缩放到具体位置
* @param position 位置
* @param completeCallback 回调函数
* @returns {Viewer}
*/
zoomToPosition(position: T_Position, completeCallback: any): this;
/**
* 飞到指定范围
* @param bounds 范围
* @param hpr 方位角
* @param completeCallback 回调函数
* @param duration 间隔时间
* @return {Viewer}
*/
flyToBounds(bounds: any, { heading, pitch, roll }: {
heading?: number;
pitch?: number;
roll?: number;
}, completeCallback: any, duration?: any): this;
/**
* 缩放到指定范围
* @param bounds 范围
* @param hpr 方位角
* @param completeCallback 回调函数
* @return {Viewer}
*/
zoomToBounds(bounds: any, { heading, pitch, roll }: {
heading?: number;
pitch?: number;
roll?: number;
}, completeCallback: any): this;
/**
* 事件订阅
* @param type 类型
* @param callback 回调函数
* @param context 上下文
* @returns {Viewer}
*/
on(type: any, callback: any, context: any): this;
/**
* 事件订阅一次
* @param type 类型
* @param callback 回调函数
* @param context 上下文
* @returns {Viewer}
*/
once(type: any, callback: any, context: any): this;
/**
* 事件订阅取消
* @param type 类型
* @param callback 回调函数
* @param context 上下文
* @returns {Viewer}
*/
off(type: any, callback: any, context: any): this;
/**
* 销毁
*/
destroy(): this;
/**
* 导出场景
* @param name
* @returns {Viewer}
*/
exportScene(name: string): this;
/**
* @hidden
* @param plugin
* @returns {Viewer}
*/
use(plugin: any): this;
/**
* @hidden
* @param plugin
* @returns {Viewer}
*/
unuse(plugin: any): this;
}
export default Viewer;