Skip to content

cesium2s


cesium2s / Viewer

类: Viewer

继承

  • Viewer

构造函数

构造函数

new Viewer(container, options?): Viewer

参数

container

string | Element

options?

Option

返回

Viewer

重写了

Cesium.Viewer.constructor

属性

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.

继承自

Cesium.Viewer.allowDataSourcesToSuspendAnimation


animation

readonly animation: Animation

Gets the Animation widget.

继承自

Cesium.Viewer.animation


baseLayerPicker

readonly baseLayerPicker: BaseLayerPicker

Gets the BaseLayerPicker.

继承自

Cesium.Viewer.baseLayerPicker


bottomContainer

readonly bottomContainer: Element

Gets the DOM element for the area at the bottom of the window containing the CreditDisplay and potentially other things.

继承自

Cesium.Viewer.bottomContainer


camera

readonly camera: Camera

Gets the camera.

继承自

Cesium.Viewer.camera


canvas

readonly canvas: HTMLCanvasElement

Gets the canvas.

继承自

Cesium.Viewer.canvas


cesiumWidget

readonly cesiumWidget: CesiumWidget

Gets the CesiumWidget.

继承自

Cesium.Viewer.cesiumWidget


clock

readonly clock: Clock

Gets the clock.

继承自

Cesium.Viewer.clock


clockTrackedDataSource

clockTrackedDataSource: DataSource

Gets or sets the data source to track with the viewer's clock.

继承自

Cesium.Viewer.clockTrackedDataSource


clockViewModel

readonly clockViewModel: ClockViewModel

Gets the clock view model.

继承自

Cesium.Viewer.clockViewModel


container

readonly container: Element

Gets the parent container.

继承自

Cesium.Viewer.container


creditDisplay

creditDisplay: CreditDisplay

Manages the list of credits to display on screen and in the lightbox.

继承自

Cesium.Viewer.creditDisplay


dataSourceDisplay

readonly dataSourceDisplay: DataSourceDisplay

Gets the display used for DataSource visualization.

继承自

Cesium.Viewer.dataSourceDisplay


dataSources

readonly dataSources: DataSourceCollection

Gets the set of DataSource instances to be visualized.

继承自

Cesium.Viewer.dataSources


ellipsoid

readonly ellipsoid: Ellipsoid

Gets the default ellipsoid for the scene.

继承自

Cesium.Viewer.ellipsoid


emitter

emitter: CesiumEventEmitter


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.

继承自

Cesium.Viewer.entities


fullscreenButton

readonly fullscreenButton: FullscreenButton

Gets the FullscreenButton.

继承自

Cesium.Viewer.fullscreenButton


geocoder

readonly geocoder: Geocoder

Gets the Geocoder.

继承自

Cesium.Viewer.geocoder


homeButton

readonly homeButton: HomeButton

Gets the HomeButton.

继承自

Cesium.Viewer.homeButton


imageryLayers

readonly imageryLayers: ImageryLayerCollection

Gets the collection of image layers that will be rendered on the globe.

继承自

Cesium.Viewer.imageryLayers


infoBox

readonly infoBox: InfoBox

Gets the info box.

继承自

Cesium.Viewer.infoBox


lensFlare?

optional lensFlare: LensFlareStage


readonly navigationHelpButton: NavigationHelpButton

Gets the NavigationHelpButton.

继承自

Cesium.Viewer.navigationHelpButton


options?

optional options: Option


popups

popups: Popup[] = []


postProcessStages

readonly postProcessStages: PostProcessStageCollection

Gets the post-process stages.

继承自

Cesium.Viewer.postProcessStages


projectionPicker

readonly projectionPicker: ProjectionPicker

Gets the ProjectionPicker.

继承自

Cesium.Viewer.projectionPicker


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.

继承自

Cesium.Viewer.resolutionScale


scene

readonly scene: Scene

Gets the scene.

继承自

Cesium.Viewer.scene


sceneModePicker

readonly sceneModePicker: SceneModePicker

Gets the SceneModePicker.

继承自

Cesium.Viewer.sceneModePicker


screenSpaceEventHandler

readonly screenSpaceEventHandler: ScreenSpaceEventHandler

Gets the screen space event handler.

继承自

Cesium.Viewer.screenSpaceEventHandler


selectedEntity

selectedEntity: Entity | undefined

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.

继承自

Cesium.Viewer.selectedEntity


selectedEntityChanged

readonly selectedEntityChanged: Event

Gets the event that is raised when the selected entity changes.

继承自

Cesium.Viewer.selectedEntityChanged


selectionIndicator

readonly selectionIndicator: SelectionIndicator

Gets the selection indicator.

继承自

Cesium.Viewer.selectionIndicator


shadowMap

readonly shadowMap: ShadowMap

Get the scene's shadow map

继承自

Cesium.Viewer.shadowMap


shadows

shadows: boolean

Determines if shadows are cast by light sources.

继承自

Cesium.Viewer.shadows


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.

继承自

Cesium.Viewer.targetFrameRate


terrainProvider

terrainProvider: TerrainProvider

The terrain provider providing surface geometry for the globe.

继承自

Cesium.Viewer.terrainProvider


terrainShadows

terrainShadows: ShadowMode

Determines if the terrain casts or shadows from light sources.

继承自

Cesium.Viewer.terrainShadows


timeline

readonly timeline: Timeline

Gets the Timeline widget.

继承自

Cesium.Viewer.timeline


trackedEntity

trackedEntity: Entity | undefined

Gets or sets the Entity instance currently being tracked by the camera.

继承自

Cesium.Viewer.trackedEntity


trackedEntityChanged

readonly trackedEntityChanged: Event

Gets the event that is raised when the tracked entity changes.

继承自

Cesium.Viewer.trackedEntityChanged


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.

继承自

Cesium.Viewer.useBrowserRecommendedResolution


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.

继承自

Cesium.Viewer.useDefaultRenderLoop


vrButton

readonly vrButton: VRButton

Gets the VRButton.

继承自

Cesium.Viewer.vrButton

方法

addFlowLightLine()

addFlowLightLine(__namedParameters): Primitive

参数

__namedParameters
color?

Color = Cesium.Color.YELLOW

positions

Cartesian3[]

speed?

number = 1

width?

number = 5

返回

Primitive

Description

添加流光线


addImageryLayer()

addImageryLayer(options): ImageryLayer

参数

options

ConstructorOptions

返回

ImageryLayer

Description

添加自定义xyz瓦片


addLabel()

addLabel(params): void

参数

params
backgroundImage

string

label

string

lnglat

[number, number]

viewer

Viewer

返回

void


addPopup()

addPopup(params): Popup

参数

params
id?

string

offset?

[number, number]

popDom

HTMLElement

position

Cartesian3

返回

Popup

Description

弹窗


asMapboxControl()

asMapboxControl(): void

返回

void

Description

cesium操作方式改为和mapboxgl的操作方式一样


destroy()

destroy(): void

Destroys the widget. Should be called if permanently removing the widget from layout.

返回

void

继承自

Cesium.Viewer.destroy


drawENUAxias()

drawENUAxias(options): object[]

参数

options
center

Cartesian3

radius?

number

width?

number

返回

object[]

Description

添加跟随点移动的ENU坐标轴


drawModelAxes()

drawModelAxes(position, orientation, length): void

参数

position

Cartesian3

orientation

Quaternion

length

number = 10

返回

void


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.

参数

mixin

ViewerMixin

The Viewer mixin to add to this instance.

options?

any

The options object to be passed to the mixin function.

返回

void

继承自

Cesium.Viewer.extend


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.

参数

target

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.

ImageryLayer | Entity | Entity[] | EntityCollection | DataSource | Cesium3DTileset | TimeDynamicPointCloud | Promise<ImageryLayer | Entity | Entity[] | EntityCollection | DataSource | Cesium3DTileset | TimeDynamicPointCloud | VoxelPrimitive>

options?

Object with the following properties:

duration?

number

The duration of the flight in seconds.

maximumHeight?

number

The maximum height at the peak of the flight.

offset?

HeadingPitchRange

The offset from the target in the local east-north-up reference frame centered at the target.

返回

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

继承自

Cesium.Viewer.flyTo


flyToPoints()

flyToPoints(padding): void

参数

padding

边距百分比,默认为0.2倍

padding

number = 0.2

points

Cartesian3[]

返回

void

Description

缩放到要素


forceResize()

forceResize(): void

This forces the widget to re-think its layout, including widget sizes and credit placement.

返回

void

继承自

Cesium.Viewer.forceResize


getCameraState()

getCameraState(): object

返回

object

destination

destination: number[]

orientation

orientation: object

orientation.heading

heading: number

orientation.pitch

pitch: number

orientation.roll

roll: number

Description

获取相机视角参数


getClampPositions()

getClampPositions(positions): Promise<Cartesian3[]>

参数

positions

Cartesian3[]

返回

Promise<Cartesian3[]>

Description

获取精确贴地形坐标

示例

ts
cesium2s.getClampPosition({viewer,lnglat:[110,20]}) //获取经度110,纬度20点的精确贴地形高度

isDestroyed()

isDestroyed(): boolean

返回

boolean

true if the object has been destroyed, false otherwise.

继承自

Cesium.Viewer.isDestroyed


isPointVisible()

isPointVisible(position): boolean

参数

position

Cartesian3

返回

boolean


load3dtiles()

load3dtiles(url, options?): Promise<Cesium3DTileset>

加载cesium3dtiles模型

参数

url

string

——tileset.json的url

options?

ConstructorOptions

——cesium支持的3dtileset相关配置

返回

Promise<Cesium3DTileset>

示例

ts
//加载3dtilest模型,并飞过去、调整高度;
const tileset = await cesium2s.load3dtiles(
   "/models/3dtiles/building/tileset.json"
  )
  viewer.flyTo(tileset)
  cesium2s.adjust3DTilesetHeight(tileset,40) //向上平移40米

loadModel()

loadModel(__namedParameters): Promise<Model | undefined>

加载gltf模型

参数

__namedParameters
bearing?

number

clampToGround?

boolean = false

id?

string

modelUrl

string

orientation?

any = {}

position

Cartesian3 | [number, number, number]

scale?

number

silhouetteColor?

Color

silhouetteSize?

number

返回

Promise<Model | undefined>


multiPolygonToGml()

multiPolygonToGml(multiPolygon, srsCode?): string

参数

multiPolygon

Feature<MultiPolygon>

srsCode?

number

返回

string

Description

多边形geojson转gml格式


off()

off(type, callback?): void

参数

type

EventType

callback?

(event) => void

返回

void

Description

事件解绑


on()

on(type, callback): void

参数

type

EventType

callback

(event) => void

返回

void

Description

事件绑定


removePopup()

removePopup(popupId): boolean

参数

popupId

string

返回

boolean

Description

移除地图上的弹窗


render()

render(): void

Renders the scene. This function is called automatically unless useDefaultRenderLoop is set to false;

返回

void

继承自

Cesium.Viewer.render


resize()

resize(): void

Resizes the widget to match the container size. This function is called automatically as needed unless useDefaultRenderLoop is set to false.

返回

void

继承自

Cesium.Viewer.resize


setCameraState()

setCameraState(options): void

参数

options
destination

[number, number, number]

orientation?

HeadingPitchRollValues

返回

void


setLensFlare()

setLensFlare(show): void

参数

show

boolean

返回

void

Description

增加透镜眩光的显示开启关闭方法


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.

参数

target

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.

ImageryLayer | Entity | Entity[] | EntityCollection | DataSource | Cesium3DTileset | TimeDynamicPointCloud | Promise<ImageryLayer | Entity | Entity[] | EntityCollection | DataSource | Cesium3DTileset | TimeDynamicPointCloud | VoxelPrimitive>

offset?

HeadingPitchRange

The offset from the center of the entity in the local east-north-up reference frame.

返回

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.

继承自

Cesium.Viewer.zoomTo