Name | Type | Description |
---|---|---|
container |
Element | String | 将包含小部件的DOM元素或ID。 |
options |
Viewer.ConstructorOptions | optional 描述初始化选项的对象 |
Throws:
-
DeveloperError :文档中不存在id为“container”的元素。
-
DeveloperError : options.SelectedImageProviderViewModel不使用BaseLayerPicker小部件时不可用,请指定options.imageryProvider选项相反。
-
DeveloperError : options.selectedTerrainProviderViewModel不使用BaseLayerPicker小部件时不可用,请指定选项.terrainProvider相反。
Example:
//Initialize the viewer widget with several custom options and mixins.
var viewer = new Cesium.Viewer('cesiumContainer', {
//Start in Columbus Viewer
sceneMode : Cesium.SceneMode.COLUMBUS_VIEW,
//Use Cesium World Terrain
terrainProvider : Cesium.createWorldTerrain(),
//Hide the base layer picker
baseLayerPicker : false,
//Use OpenStreetMaps
imageryProvider : new Cesium.OpenStreetMapImageryProvider({
url : 'https://a.tile.openstreetmap.org/'
}),
skyBox : new Cesium.SkyBox({
sources : {
positiveX : 'stars/TychoSkymapII.t3_08192x04096_80_px.jpg',
negativeX : 'stars/TychoSkymapII.t3_08192x04096_80_mx.jpg',
positiveY : 'stars/TychoSkymapII.t3_08192x04096_80_py.jpg',
negativeY : 'stars/TychoSkymapII.t3_08192x04096_80_my.jpg',
positiveZ : 'stars/TychoSkymapII.t3_08192x04096_80_pz.jpg',
negativeZ : 'stars/TychoSkymapII.t3_08192x04096_80_mz.jpg'
}
}),
// Show Columbus View map with Web Mercator projection
mapProjection : new Cesium.WebMercatorProjection()
});
//Add basic drag and drop functionality
viewer.extend(Cesium.viewerDragDropMixin);
//Show a pop-up alert if we encounter an error when processing a dropped file
viewer.dropError.addEventListener(function(dropHandler, name, error) {
console.log(error);
window.alert(error);
});
Demo:
See:
Members
readonly animation : Animation
readonly baseLayerPicker : BaseLayerPicker
CreditDisplay
和其他可能的东西。readonly camera : Camera
readonly cesiumWidget : CesiumWidget
readonly clock : Clock
clockTrackedDataSource : DataSource
readonly clockViewModel : ClockViewModel
readonly dataSourceDisplay : DataSourceDisplay
DataSource
可视化的显示。readonly dataSources : DataSourceCollection
DataSource
个实例集。readonly entities : EntityCollection
dataSourceDisplay.defaultDataSource.entities
的捷径。readonly fullscreenButton : FullscreenButton
readonly geocoder : Geocoder
readonly homeButton : HomeButton
readonly imageryLayers : ImageryLayerCollection
readonly infoBox : InfoBox
readonly navigationHelpButton : NavigationHelpButton
readonly postProcessStages : PostProcessStageCollection
readonly projectionPicker : ProjectionPicker
-
Default Value:
1.0
readonly scene : Scene
readonly sceneModePicker : SceneModePicker
readonly screenSpaceEventHandler : ScreenSpaceEventHandler
selectedEntity : Entity|undefined
readonly selectedEntityChanged : Event
readonly selectionIndicator : SelectionIndicator
readonly shadowMap : ShadowMap
useDefaultRenderLoop
时,获取或设置小部件的目标帧速率
是真的。如果未定义,则浏览器的requestAnimationFrame
实现
确定帧速率。如果已定义,则此值必须大于0。更高的价值
否则,实现将没有底层框架的动画效果。terrainProvider : TerrainProvider
terrainShadows : ShadowMode
readonly timeline : Timeline
trackedEntity : Entity|undefined
readonly trackedEntityChanged : Event
Viewer#resolutionScale
是否仍将生效
此标志为真或假。-
Default Value:
true
render
循环。
如果设置为true,小部件将使用requestAnimationFrame
来
执行小部件的呈现和大小调整,以及驱动
模拟时钟。如果设置为false,则必须手动调用
resize
,呈现方法
作为自定义渲染循环的一部分。如果在渲染过程中发生错误,则Scene
将引发renderError
事件,并且此属性
将设置为false。必须将其设置回true才能继续渲染
在错误之后。readonly vrButton : VRButton
Methods
Name | Type | Description |
---|---|---|
mixin |
Viewer.ViewerMixin | 要添加到此实例的查看器mixin。 |
options |
Object | optional 要传递给mixin函数的options对象。 |
See:
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.
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
target |
Entity | Array.<Entity> | EntityCollection | DataSource | ImageryLayer | Cesium3DTileset | TimeDynamicPointCloud | Promise.<(Entity|Array.<Entity>|EntityCollection|DataSource|ImageryLayer|Cesium3DTileset|TimeDynamicPointCloud)> | 要查看的实体、实体数组、实体集合、数据源、CESUM3DTileset、点云或图像层。您还可以传递一个解析为前面提到的类型之一的promise。 | ||||||||||||||||
options |
Object | optional
具有以下属性的对象:
|
Returns:
Returns:
useDefaultRenderLoop
设置为false;useDefaultRenderLoop
设置为false。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.
Name | Type | Description |
---|---|---|
target |
Entity | Array.<Entity> | EntityCollection | DataSource | ImageryLayer | Cesium3DTileset | TimeDynamicPointCloud | Promise.<(Entity|Array.<Entity>|EntityCollection|DataSource|ImageryLayer|Cesium3DTileset|TimeDynamicPointCloud)> | 要查看的实体、实体数组、实体集合、数据源、CESUM3DTileset、点云或图像层。您还可以传递一个解析为前面提到的类型之一的promise。 |
offset |
HeadingPitchRange | optional 从局部“东-北”向上参照系中图元中心的偏移。 |
Returns:
Type Definitions
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
animation |
Boolean |
<optional> |
true | 如果设置为false,则不会创建动画小部件。 |
baseLayerPicker |
Boolean |
<optional> |
true | 如果设置为false,则不会创建BaseLayerPicker小部件。 |
fullscreenButton |
Boolean |
<optional> |
true | 如果设置为false,则不会创建FullscreenButton小部件。 |
vrButton |
Boolean |
<optional> |
false | 如果设置为true,将创建VRButton小部件。 |
geocoder |
Boolean | Array.<GeocoderService> |
<optional> |
true | 如果设置为false,则不会创建Geocoder小部件。 |
homeButton |
Boolean |
<optional> |
true | 如果设置为false,则不会创建HomeButton小部件。 |
infoBox |
Boolean |
<optional> |
true | 如果设置为false,则不会创建InfoBox小部件。 |
sceneModePicker |
Boolean |
<optional> |
true | 如果设置为false,则不会创建SceneModePicker小部件。 |
selectionIndicator |
Boolean |
<optional> |
true | 如果设置为false,则不会创建SelectionIndicator小部件。 |
timeline |
Boolean |
<optional> |
true | 如果设置为false,则不会创建时间线小部件。 |
navigationHelpButton |
Boolean |
<optional> |
true | 如果设置为false,则不会创建导航帮助按钮。 |
navigationInstructionsInitiallyVisible |
Boolean |
<optional> |
true | 如果导航指令最初应该可见,则为True,如果在用户明确单击按钮之前不应显示导航指令,则为false。 |
scene3DOnly |
Boolean |
<optional> |
false | 当true 时,每个几何体实例将仅以3D形式呈现,以节省GPU内存。 |
shouldAnimate |
Boolean |
<optional> |
false | true ,如果时钟应尝试提前模拟时间,否则为false 。此选项优先于设置Viewer#clockViewModel 。 |
clockViewModel |
ClockViewModel |
<optional> |
new ClockViewModel(clock) | 用于控制当前时间的时钟视图模型。 |
selectedImageryProviderViewModel |
ProviderViewModel |
<optional> |
当前基础图像层的视图模型,如果未提供,则使用第一个可用的基础层。此值仅在“baseLayerPicker”设置为true时有效。 | |
imageryProviderViewModels |
Array.<ProviderViewModel> |
<optional> |
createDefaultImageryProviderViewModels() | 可从BaseLayerPicker中选择的ProviderViewModels数组。此值仅在“baseLayerPicker”设置为true时有效。 |
selectedTerrainProviderViewModel |
ProviderViewModel |
<optional> |
当前基础地形图层的视图模型,如果未提供,则使用第一个可用的基础图层。此值仅在“baseLayerPicker”设置为true时有效。 | |
terrainProviderViewModels |
Array.<ProviderViewModel> |
<optional> |
createDefaultTerrainProviderViewModels() | 可从BaseLayerPicker中选择的ProviderViewModels数组。此值仅在“baseLayerPicker”设置为true时有效。 |
imageryProvider |
ImageryProvider |
<optional> |
createWorldImagery() | 要使用的图像提供商。此值仅在“baseLayerPicker”设置为false时有效。 |
terrainProvider |
TerrainProvider |
<optional> |
new EllipsoidTerrainProvider() | 要使用的地形提供程序 |
skyBox |
SkyBox | false |
<optional> |
用来渲染星星的天空盒。当undefined 时,使用默认的星形。如果设置为false ,则不会添加skyBox、太阳或月亮。 |
|
skyAtmosphere |
SkyAtmosphere | false |
<optional> |
蓝色的天空,以及环绕地球的光辉。设置为false 可将其关闭。 |
|
fullscreenElement |
Element | String |
<optional> |
document.body | 当按下全屏按钮时要置于全屏模式的元素或标识。 |
useDefaultRenderLoop |
Boolean |
<optional> |
true | 如果此小部件应控制渲染循环,则为True,否则为false。 |
targetFrameRate |
Number |
<optional> |
使用默认渲染循环时的目标帧速。 | |
showRenderLoopErrors |
Boolean |
<optional> |
true | 如果为true,则当出现呈现循环错误时,此小部件将自动向用户显示包含错误的HTML面板。 |
useBrowserRecommendedResolution |
Boolean |
<optional> |
true | 如果为true,则以浏览器建议的分辨率渲染,并忽略window.devicePixelRatio 。 |
automaticallyTrackDataSourceClocks |
Boolean |
<optional> |
true | 如果为true,此小部件将自动跟踪新添加数据源的时钟设置,并在数据源的时钟更改时更新。如果要独立配置时钟,请将此设置为false。 |
contextOptions |
Object |
<optional> |
与options 对应的上下文和WebGL创建属性传递给Scene 。 |
|
sceneMode |
SceneMode |
<optional> |
SceneMode.SCENE3D | 初始场景模式。 |
mapProjection |
MapProjection |
<optional> |
new GeographicProjection() | 要在二维和哥伦布视图模式中使用的地图投影。 |
globe |
Globe | false |
<optional> |
new Globe(mapProjection.ellipsoid) | 要在场景中使用的地球仪。如果设置为false ,则不会添加任何球体。 |
orderIndependentTranslucency |
Boolean |
<optional> |
true | 如果为true且配置支持它,请使用与顺序无关的半透明。 |
creditContainer |
Element | String |
<optional> |
将包含CreditDisplay 的DOM元素或ID。如果未指定,则信用证将添加到小部件本身的底部。 |
|
creditViewport |
Element | String |
<optional> |
包含CreditDisplay 创建的信用弹出窗口的DOM元素或ID。如果没有指定,它将出现在小部件本身的上方。 |
|
dataSources |
DataSourceCollection |
<optional> |
new DataSourceCollection() | 由小部件可视化的数据源集合。如果提供了此参数, 当调用方不被销毁时,该实例将被假定为不被销毁。 |
terrainExaggeration |
Number |
<optional> |
1.0 | 用来夸大地形的标量。请注意,地形放大不会修改任何其他基本体,因为它们相对于椭球体定位。 |
shadows |
Boolean |
<optional> |
false | 确定阴影是否由光源投射。 |
terrainShadows |
ShadowMode |
<optional> |
ShadowMode.RECEIVE_ONLY | 确定地形是投射还是接收来自光源的阴影。 |
mapMode2D |
MapMode2D |
<optional> |
MapMode2D.INFINITE_SCROLL | 确定二维贴图是可旋转的还是可以在水平方向无限滚动。 |
projectionPicker |
Boolean |
<optional> |
false | 如果设置为true,将创建ProjectionPicker小部件。 |
requestRenderMode |
Boolean |
<optional> |
false | 如果为true,则仅在需要时渲染帧(由场景中的更改决定)。启用可减少应用程序的CPU/GPU使用量,并在移动设备上使用更少的电池,但需要使用Scene#requestRender 在这种模式下显式呈现新帧。在许多情况下,在API的其他部分对场景进行更改后,这是必需的。见Improving Performance with Explicit Rendering。 |
maximumRenderTimeChange |
Number |
<optional> |
0.0 | 如果requestRenderMode为true,则此值定义请求渲染之前允许的模拟时间的最大更改。见Improving Performance with Explicit Rendering。 |
Name | Type | Description |
---|---|---|
viewer |
Viewer | 查看器实例。 |
options |
Object | 要传递给mixin函数的Options对象。 |