Appearance
Class: Viewer
场景视图,继承于 cesiumJS 的 Viewer 类,保留下 viewer 一些属性和方法 默认鼠标操作为左键平移,滚轮缩放,右键旋转,ctrl+ 左键旋转,ctrl+ 右键微缩放。
Hierarchy
Viewer↳
Viewer
Table of contents
Constructors
Properties
- ready
- provider
- container
- creditDisplay
- bottomContainer
- cesiumWidget
- selectionIndicator
- infoBox
- geocoder
- homeButton
- sceneModePicker
- projectionPicker
- baseLayerPicker
- navigationHelpButton
- animation
- timeline
- fullscreenButton
- vrButton
- dataSourceDisplay
- entities
- dataSources
- canvas
- scene
- shadows
- terrainShadows
- shadowMap
- imageryLayers
- terrainProvider
- camera
- postProcessStages
- clock
- clockViewModel
- screenSpaceEventHandler
- targetFrameRate
- useDefaultRenderLoop
- resolutionScale
- useBrowserRecommendedResolution
- allowDataSourcesToSuspendAnimation
- trackedEntity
- selectedEntity
- selectedEntityChanged
- trackedEntityChanged
- clockTrackedDataSource
- mapOptions
Accessors
Methods
- extend
- forceResize
- render
- isDestroyed
- zoomTo
- flyTo
- flyToHome
- exitFullscreen
- fullScreen
- getCameraFocus
- modeSwitchTo2D
- modeSwitchTo3D
- resize
- saveSceneAsIMG
- setHome
- setNorth
- zoomIn
- zoomOut
- destroy
Constructors
constructor
• new Viewer(mapContainer, options?): Viewer
场景视图,继承于 cesiumjs 的 Viewer 类,保留下 viewer 一些属性和方法 默认鼠标操作为左键平移,滚轮缩放,右键旋转,ctrl+ 左键旋转,ctrl+ 右键微缩放。
Parameters
| Name | Type | Description |
|---|---|---|
mapContainer | string | Element | DOM 元素或者元素 ID |
options? | MapOptions | MapOptions |
Returns
Remarks
Viewer.ConstructorOptions 类型:
| Name | Type | Attributes | Default | Description | | ----------------- | ----------------------------- | ---------- | -------------------------------- | ------------------------------- | ----------------------------------- | | shadows | Boolean | optional | false | 是否开启由太阳照射的阴影. | | terrainProvider | TerrainProvider | optional | TerrainManager.createNoTerrain() | 配置加载的地形数据. | | baseMapMode | BaseMapMode | optional | BaseMapMode.TIANDITU | 底图模式, 默认为天地图影像底图. | | location | Boolean | optional | true | 是否开启场景底部位置信息控件. | | baseLayerPicker | Boolean | optional | true | 是否开启场景底图选择控件. | | sceneMode | SceneMode | optional | SceneMode.SCENE3D | 视图模式, 默认3D模式. | | copyrightLogo | Boolean | optional | true | 公司版权标识, 默认显示. | | navigation | Navigation.ConstructorOptions | Boolean | optional | | 三维导航控件Navigation, 默认开启. |
Example
js
// 创建默认场景
const viewer = new joDVF.Viewer("container");
// 隐藏场景中的控件
const viewer = new joDVF.Viewer("container", {
location: false,
baseLayerPicker: false,
navigation: false
});
// 设置场景默认底图
const viewer = new joDVF.Viewer("container", {
baseMapMode: joDVF.BaseMapMode.ESRI
});Overrides
CesiumViewer.constructor
Defined in
src/engine/Viewer.ts:185
Properties
ready
• Readonly ready: boolean
Returns true when the terrain provider has been successfully created. Otherwise, returns false.
Inherited from
CesiumViewer.ready
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44662
provider
• Readonly provider: TerrainProvider
The terrain provider providing surface geometry to a globe. Do not use until Terrain.readyEvent is raised.
Inherited from
CesiumViewer.provider
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44666
container
• Readonly container: Element
Gets the parent container.
Inherited from
CesiumViewer.container
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44670
creditDisplay
• creditDisplay: CreditDisplay
Manages the list of credits to display on screen and in the lightbox.
Inherited from
CesiumViewer.creditDisplay
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44674
bottomContainer
• Readonly bottomContainer: Element
Gets the DOM element for the area at the bottom of the window containing the CreditDisplay and potentially other things.
Inherited from
CesiumViewer.bottomContainer
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44679
cesiumWidget
• Readonly cesiumWidget: CesiumWidget
Gets the CesiumWidget.
Inherited from
CesiumViewer.cesiumWidget
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44683
selectionIndicator
• Readonly selectionIndicator: SelectionIndicator
Gets the selection indicator.
Inherited from
CesiumViewer.selectionIndicator
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44687
infoBox
• Readonly infoBox: InfoBox
Gets the info box.
Inherited from
CesiumViewer.infoBox
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44691
geocoder
• Readonly geocoder: Geocoder
Gets the Geocoder.
Inherited from
CesiumViewer.geocoder
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44695
homeButton
• Readonly homeButton: HomeButton
Gets the HomeButton.
Inherited from
CesiumViewer.homeButton
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44699
sceneModePicker
• Readonly sceneModePicker: SceneModePicker
Gets the SceneModePicker.
Inherited from
CesiumViewer.sceneModePicker
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44703
projectionPicker
• Readonly projectionPicker: ProjectionPicker
Gets the ProjectionPicker.
Inherited from
CesiumViewer.projectionPicker
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44707
baseLayerPicker
• Readonly baseLayerPicker: BaseLayerPicker
Gets the BaseLayerPicker.
Inherited from
CesiumViewer.baseLayerPicker
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44711
navigationHelpButton
• Readonly navigationHelpButton: NavigationHelpButton
Gets the NavigationHelpButton.
Inherited from
CesiumViewer.navigationHelpButton
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44715
animation
• Readonly animation: Animation
Gets the Animation widget.
Inherited from
CesiumViewer.animation
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44719
timeline
• Readonly timeline: Timeline
Gets the Timeline widget.
Inherited from
CesiumViewer.timeline
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44723
fullscreenButton
• Readonly fullscreenButton: FullscreenButton
Gets the FullscreenButton.
Inherited from
CesiumViewer.fullscreenButton
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44727
vrButton
• Readonly vrButton: VRButton
Gets the VRButton.
Inherited from
CesiumViewer.vrButton
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44731
dataSourceDisplay
• Readonly dataSourceDisplay: DataSourceDisplay
Gets the display used for DataSource visualization.
Inherited from
CesiumViewer.dataSourceDisplay
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44735
entities
• Readonly entities: EntityCollection
Gets the collection of entities not tied to a particular data source. This is a shortcut to [dataSourceDisplay.defaultDataSource.entities]Viewer#dataSourceDisplay.
Inherited from
CesiumViewer.entities
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44740
dataSources
• Readonly dataSources: DataSourceCollection
Gets the set of DataSource instances to be visualized.
Inherited from
CesiumViewer.dataSources
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44744
canvas
• Readonly canvas: HTMLCanvasElement
Gets the canvas.
Inherited from
CesiumViewer.canvas
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44748
scene
• Readonly scene: Scene
Gets the scene.
Inherited from
CesiumViewer.scene
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44752
shadows
• shadows: boolean
Determines if shadows are cast by light sources.
Inherited from
CesiumViewer.shadows
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44756
terrainShadows
• terrainShadows: ShadowMode
Determines if the terrain casts or shadows from light sources.
Inherited from
CesiumViewer.terrainShadows
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44760
shadowMap
• Readonly shadowMap: ShadowMap
Get the scene's shadow map
Inherited from
CesiumViewer.shadowMap
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44764
imageryLayers
• Readonly imageryLayers: ImageryLayerCollection
Gets the collection of image layers that will be rendered on the globe.
Inherited from
CesiumViewer.imageryLayers
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44768
terrainProvider
• terrainProvider: TerrainProvider
The terrain provider providing surface geometry for the globe.
Inherited from
CesiumViewer.terrainProvider
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44772
camera
• Readonly camera: Camera
Gets the camera.
Inherited from
CesiumViewer.camera
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44776
postProcessStages
• Readonly postProcessStages: PostProcessStageCollection
Gets the post-process stages.
Inherited from
CesiumViewer.postProcessStages
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44780
clock
• Readonly clock: Clock
Gets the clock.
Inherited from
CesiumViewer.clock
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44784
clockViewModel
• Readonly clockViewModel: ClockViewModel
Gets the clock view model.
Inherited from
CesiumViewer.clockViewModel
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44788
screenSpaceEventHandler
• Readonly screenSpaceEventHandler: ScreenSpaceEventHandler
Gets the screen space event handler.
Inherited from
CesiumViewer.screenSpaceEventHandler
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44792
targetFrameRate
• targetFrameRate: number
Gets or sets the target frame rate of the widget when useDefaultRenderLoop is true. If undefined, the browser's requestAnimationFrame implementation determines the frame rate. If defined, this value must be greater than 0. A value higher than the underlying requestAnimationFrame implementation will have no effect.
Inherited from
CesiumViewer.targetFrameRate
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44799
useDefaultRenderLoop
• useDefaultRenderLoop: boolean
Gets or sets whether or not this widget should control the render loop. If true the widget will use requestAnimationFrame to perform rendering and resizing of the widget, as well as drive the simulation clock. If set to false, you must manually call the resize, render methods as part of a custom render loop. If an error occurs during rendering, Scene's renderError event will be raised and this property will be set to false. It must be set back to true to continue rendering after the error.
Inherited from
CesiumViewer.useDefaultRenderLoop
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44811
resolutionScale
• resolutionScale: number
Gets or sets a scaling factor for rendering resolution. Values less than 1.0 can improve performance on less powerful devices while values greater than 1.0 will render at a higher resolution and then scale down, resulting in improved visual fidelity. For example, if the widget is laid out at a size of 640x480, setting this value to 0.5 will cause the scene to be rendered at 320x240 and then scaled up while setting it to 2.0 will cause the scene to be rendered at 1280x960 and then scaled down.
Inherited from
CesiumViewer.resolutionScale
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44820
useBrowserRecommendedResolution
• useBrowserRecommendedResolution: boolean
Boolean flag indicating if the browser's recommended resolution is used. If true, the browser's device pixel ratio is ignored and 1.0 is used instead, effectively rendering based on CSS pixels instead of device pixels. This can improve performance on less powerful devices that have high pixel density. When false, rendering will be in device pixels. Viewer#resolutionScale will still take effect whether this flag is true or false.
Inherited from
CesiumViewer.useBrowserRecommendedResolution
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44829
allowDataSourcesToSuspendAnimation
• allowDataSourcesToSuspendAnimation: boolean
Gets or sets whether or not data sources can temporarily pause animation in order to avoid showing an incomplete picture to the user. For example, if asynchronous primitives are being processed in the background, the clock will not advance until the geometry is ready.
Inherited from
CesiumViewer.allowDataSourcesToSuspendAnimation
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44836
trackedEntity
• trackedEntity: Entity
Gets or sets the Entity instance currently being tracked by the camera.
Inherited from
CesiumViewer.trackedEntity
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44840
selectedEntity
• selectedEntity: Entity
Gets or sets the object instance for which to display a selection indicator.
If a user interactively picks a Cesium3DTilesFeature instance, then this property will contain a transient Entity instance with a property named "feature" that is the instance that was picked.
Inherited from
CesiumViewer.selectedEntity
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44848
selectedEntityChanged
• Readonly selectedEntityChanged: Event<(...args: any[]) => void>
Gets the event that is raised when the selected entity changes.
Inherited from
CesiumViewer.selectedEntityChanged
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44852
trackedEntityChanged
• Readonly trackedEntityChanged: Event<(...args: any[]) => void>
Gets the event that is raised when the tracked entity changes.
Inherited from
CesiumViewer.trackedEntityChanged
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44856
clockTrackedDataSource
• clockTrackedDataSource: DataSource
Gets or sets the data source to track with the viewer's clock.
Inherited from
CesiumViewer.clockTrackedDataSource
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44860
mapOptions
• mapOptions: MapOptions & SceneOptions
map 相关参数
Memberof
Viewer
Defined in
src/engine/Viewer.ts:130
Accessors
controlManager
• get controlManager(): ControlManager
获取控件实例
Returns
ControlManager
Memberof
Viewer
Defined in
src/engine/Viewer.ts:798
homeDestination
• get homeDestination(): Cartesian3
场景初始化时默认位置
Returns
Cartesian3
Memberof
Viewer
Defined in
src/engine/Viewer.ts:808
homeOrientation
• get homeOrientation(): HeadingPitchRoll
场景初始化时默认朝向
Returns
HeadingPitchRoll
Memberof
Viewer
Defined in
src/engine/Viewer.ts:818
baseMapMode
• get baseMapMode(): BaseMapMode
获取或设置场景瓦片底图模式
Returns
Memberof
Viewer
Defined in
src/engine/Viewer.ts:828
Methods
extend
▸ extend(mixin, options?): void
Extends the base viewer functionality with the provided mixin. A mixin may add additional properties, functions, or other behavior to the provided viewer instance.
Parameters
| Name | Type | Description |
|---|---|---|
mixin | ViewerMixin | The Viewer mixin to add to this instance. |
options? | any | The options object to be passed to the mixin function. |
Returns
void
Inherited from
CesiumViewer.extend
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44868
forceResize
▸ forceResize(): void
This forces the widget to re-think its layout, including widget sizes and credit placement.
Returns
void
Inherited from
CesiumViewer.forceResize
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44879
render
▸ render(): void
Renders the scene. This function is called automatically unless useDefaultRenderLoop is set to false;
Returns
void
Inherited from
CesiumViewer.render
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44884
isDestroyed
▸ isDestroyed(): boolean
Returns
boolean
true if the object has been destroyed, false otherwise.
Inherited from
CesiumViewer.isDestroyed
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44888
zoomTo
▸ zoomTo(target, offset?): Promise<boolean>
Asynchronously sets the camera to view the provided entity, entities, or data source. If the data source is still in the process of loading or the visualization is otherwise still loading, this method waits for the data to be ready before performing the zoom.
The offset is heading/pitch/range in the local east-north-up reference frame centered at the center of the bounding sphere. The heading and the pitch angles are defined in the local east-north-up reference frame. The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch angles are above the plane. Negative pitch angles are below the plane. The range is the distance from the center. If the range is zero, a range will be computed such that the whole bounding sphere is visible.
In 2D, there must be a top down view. The camera will be placed above the target looking down. The height above the target will be the range. The heading will be determined from the offset. If the heading cannot be determined from the offset, the heading will be north.
Parameters
| Name | Type | Description |
|---|---|---|
target | Entity | EntityCollection | DataSource | Entity[] | Cesium3DTileset | ImageryLayer | TimeDynamicPointCloud | Promise<Entity | EntityCollection | DataSource | Entity[] | Cesium3DTileset | ImageryLayer | TimeDynamicPointCloud | VoxelPrimitive> | The entity, array of entities, entity collection, data source, Cesium3DTileset, point cloud, or imagery layer to view. You can also pass a promise that resolves to one of the previously mentioned types. |
offset? | HeadingPitchRange | The offset from the center of the entity in the local east-north-up reference frame. |
Returns
Promise<boolean>
A Promise that resolves to true if the zoom was successful or false if the target is not currently visualized in the scene or the zoom was cancelled.
Inherited from
CesiumViewer.zoomTo
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44912
flyTo
▸ flyTo(target, options?): Promise<boolean>
Flies the camera to the provided entity, entities, or data source. If the data source is still in the process of loading or the visualization is otherwise still loading, this method waits for the data to be ready before performing the flight.
The offset is heading/pitch/range in the local east-north-up reference frame centered at the center of the bounding sphere. The heading and the pitch angles are defined in the local east-north-up reference frame. The heading is the angle from y axis and increasing towards the x axis. Pitch is the rotation from the xy-plane. Positive pitch angles are above the plane. Negative pitch angles are below the plane. The range is the distance from the center. If the range is zero, a range will be computed such that the whole bounding sphere is visible.
In 2D, there must be a top down view. The camera will be placed above the target looking down. The height above the target will be the range. The heading will be determined from the offset. If the heading cannot be determined from the offset, the heading will be north.
Parameters
| Name | Type | Description |
|---|---|---|
target | Entity | EntityCollection | DataSource | Entity[] | Cesium3DTileset | ImageryLayer | TimeDynamicPointCloud | Promise<Entity | EntityCollection | DataSource | Entity[] | Cesium3DTileset | ImageryLayer | TimeDynamicPointCloud | VoxelPrimitive> | The entity, array of entities, entity collection, data source, Cesium3DTileset, point cloud, or imagery layer to view. You can also pass a promise that resolves to one of the previously mentioned types. |
options? | Object | Object with the following properties: |
options.duration? | number | The duration of the flight in seconds. |
options.maximumHeight? | number | The maximum height at the peak of the flight. |
options.offset? | HeadingPitchRange | The offset from the target in the local east-north-up reference frame centered at the target. |
Returns
Promise<boolean>
A Promise that resolves to true if the flight was successful or false if the target is not currently visualized in the scene or the flight was cancelled. //TODO: Cleanup entity mentions
Inherited from
CesiumViewer.flyTo
Defined in
node_modules/joCesium/Source/joCesium.d.ts:44934
flyToHome
▸ flyToHome(): void
飞行到场景 home 点的位置
Returns
void
Memberof
Viewer
Defined in
src/engine/Viewer.ts:372
exitFullscreen
▸ exitFullscreen(): void
退出全屏
Returns
void
Memberof
Viewer
Defined in
src/engine/Viewer.ts:390
fullScreen
▸ fullScreen(): void
场景全屏
Returns
void
Memberof
Viewer
Defined in
src/engine/Viewer.ts:399
getCameraFocus
▸ getCameraFocus(inWorldCoordinates?, result?): Cartesian3
获取当前 Viewer 的相机焦点
Parameters
| Name | Type | Description |
|---|---|---|
inWorldCoordinates? | boolean | 若要在世界坐标系中获取焦点,则为 true;否则,在投影特定的地图坐标系中获取焦点,单位为米。 主要是区别三维地球模式和其他模式 |
result? | Cartesian3 | 返回的结果对象 |
Returns
Cartesian3
{Cartesian3} 修改后的结果参数,如果没有提供新实例,则为新实例;如果没有焦点,则为 undefined
Memberof
Viewer
Defined in
src/engine/Viewer.ts:412
modeSwitchTo2D
▸ modeSwitchTo2D(duration?): void
切换为二维模式
Parameters
| Name | Type |
|---|---|
duration? | number |
Returns
void
Memberof
Viewer
Defined in
src/engine/Viewer.ts:475
modeSwitchTo3D
▸ modeSwitchTo3D(duration?): void
切换为三维模式
Parameters
| Name | Type |
|---|---|
duration? | number |
Returns
void
Memberof
Viewer
Defined in
src/engine/Viewer.ts:505
resize
▸ resize(): void
重绘当前屏幕
Returns
void
Memberof
Viewer
Overrides
CesiumViewer.resize
Defined in
src/engine/Viewer.ts:533
saveSceneAsIMG
▸ saveSceneAsIMG(width?, height?, type?, quality?): string
屏幕截图
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
width? | number | undefined | 图片宽度,默认场景宽度 |
height? | number | undefined | 图片高度,默认场景高度 |
type? | string | undefined | 图片格式,默认使用 PNG 格式 |
quality? | number | 0.92 | 图片质量,默认不传值,在指定图片格式为 image/jpeg 或 image/webp 的情况下,可以从 0 到 1 的区间内选择图片的质量。 如果超出取值范围,将会使用默认值 0.92。其他参数会被忽略 |
Returns
string
Memberof
Viewer
Defined in
src/engine/Viewer.ts:548
setHome
▸ setHome(destination, orientation): void
设置初始位置和视角
Parameters
| Name | Type | Description |
|---|---|---|
destination | Cartesian3 | home 位置 |
orientation | HeadingPitchRoll | home 视角 |
Returns
void
Memberof
Viewer
Defined in
src/engine/Viewer.ts:584
setNorth
▸ setNorth(): boolean
快速指北
Returns
boolean
Memberof
Viewer
Defined in
src/engine/Viewer.ts:600
zoomIn
▸ zoomIn(): void
场景放大
Returns
void
Memberof
Viewer
Defined in
src/engine/Viewer.ts:647
zoomOut
▸ zoomOut(): void
场景缩小
Returns
void
Memberof
Viewer
Defined in
src/engine/Viewer.ts:722
destroy
▸ destroy(): void
销毁并释放该对象
Returns
void
Overrides
CesiumViewer.destroy
Defined in
src/engine/Viewer.ts:840

