当前位置: 首页 > 工具软件 > cesium > 使用案例 >

Cesium-Viewer

陆展
2023-12-01

Viewer

new Cesium.Viewer(container, options)

Widgets/Viewer/Viewer.js 325
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.

一个建造应用的基础控件。
它合成了全部的标准Cesium控件到一个可以重复使用的包。
这个控件常常可以通过使用mixins(混合)进行扩展。大概是混合标准控件的意思
它通常为各种应用添加有用的功能。

NameTypeDescription
containerElement,StringThe DOM element or ID that will contain the widget.
optionsViewer.ConstructorOptionsoptionalObject describing initialization options.

Throws:

DeveloperError : Element with id “container” does not exist in the document.

DeveloperError : options.selectedImageryProviderViewModel is not available when not using the BaseLayerPicker widget, specify options.imageryProvider instead.

DeveloperError : options.selectedTerrainProviderViewModel is not available when not using the BaseLayerPicker widget, specify options.terrainProvider instead.

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:

Cesium Sandcastle Hello World Demo

See:

Animation
BaseLayerPicker
CesiumWidget
FullscreenButton
HomeButton
SceneModePicker
Timeline
viewerDragDropMixin

Members:

camera

readonly camera : Camera

Widgets/Viewer/Viewer.js 1171

Gets the camera. 

clock

readonly clock : Clock

Widgets/Viewer/Viewer.js 1196

Gets the clock. 

entities

readonly entities : EntityCollection

Widgets/Viewer/Viewer.js 1054

Gets the collection of entities not tied to a particular data source. This is a shortcut to dataSourceDisplay.defaultDataSource.entities. 

EntityCollection

new Cesium.EntityCollection(owner)

DataSources/EntityCollection.js 5

An observable collection of Entity instances where each entity has a unique id. 

Members:

Methods:

add(entity) → Entity

DataSources/EntityCollection.js 271

Add an entity to the collection.
NameTypeDescription
entityEntity or Entity.ConstructorOptionsThe entity to be added.
remove(entity) → Boolean

DataSources/EntityCollection.js 311

Removes an entity from the collection.
NameTypeDescription
entityEntityThe entity to be removed.

Returns:
true if the item was removed, false if it did not exist in the collection.

removeAll()

DataSources/EntityCollection.js 367

Removes all Entities from the collection. 

Returns:

The entity that was added.

Throws:

DeveloperError : An entity with already exists in this collection.

trackedEntity

trackedEntity : Entity|undefined

Widgets/Viewer/Viewer.js 1333

Gets or sets the Entity instance currently being tracked by the camera. 
 类似资料: