Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
container |
Element | String | Specifies the Document Object Model (DOM) or ID that holds the HTML element of the viewer component. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
optional
The object has the following properties:
|
Throws:
-
DeveloperError : The "container" element with this ID does not exist in the document.
-
DeveloperError : when using the BaseLayerPicker component, options.imageryProvider is not available, please change to the specified options.selectedImageryProviderViewModel.
-
DeveloperError : when using the BaseLayerPicker component, options.terrainProvider is not available, please change to the specified options.selectedTerrainProviderViewModel.
-
DeveloperError : When using the BaseLayerPicker component, options.selectedImageryProviderViewModel is not available, please change to the specified options.imageryProvider.
-
DeveloperError : when using the BaseLayerPicker component, options.selectedTerrainProviderViewModel is not available, please change to the specified options.terrainProvider .
Example:
//Initialize the viewer component
var viewer = new Cesium.Viewer('cesiumContainer', {
//Use STK World Terrain
terrainProvider : new Cesium.CesiumTerrainProvider({
url : 'https://assets.agi.com/stk-terrain/world'
}),
//Use OpenStreetMaps
imageryProvider : Cesium.createOpenStreetMapImageryProvider({
url : 'https://a.tile.openstreetmap.org/'
}),
});
//Add basic drag and drop
viewer.extend(Cesium.viewerDragDropMixin);
//An error was encountered while processing the deleted file, and a pop-up warning was displayed.
viewer.dropError.addEventListener(function(dropHandler, name, error) {
console.log(error);
window.alert(error);
});
See:
Members
-
Gets or sets whether the data source can temporarily pause the animation to avoid displaying incomplete images to the user. For example, if the background is processing an asynchronous function, the clock will not advance until the geometry is ready.
-
readonlyanimation : Animation
-
Get the Animation component.
-
readonlybaseLayerPicker : BaseLayerPicker
-
Get the base layer picker (BaseLayerPicker) object.
-
Get the DOM element at the bottom of the window containing
CreditDisplay
and other potential information. -
readonlycamera : Camera
-
Get the camera object.
-
Get the canvas object.
-
Get the Cesium trademark element.
-
readonlycesiumWidget : CesiumWidget
-
Get the CesiumWidget object.
-
readonlyclock : Clock
-
Get the clock object.
-
readonlyclockViewModel : ClockViewModel
-
Get the clock view model.
-
Get the parent container.
-
readonlydataSourceDisplay : DataSourceDisplay
-
Get the display for
DataSource
. -
readonlydataSources : DataSourceCollection
-
Gets or sets the collection of
DataSource
instances of the data source to be visualized. -
readonlyentities : EntityCollection
-
Get a collection of entities that are independent of a particular data source. This is a shortcut to access
dataSourceDisplay.defaultDataSource.entities
. -
readonlyfullscreenButton : FullscreenButton
-
Get the full screen button (FullscreenButton) object.
-
readonlygeocoder : Geocoder
-
Get a geocoder object.
-
readonlyhomeButton : HomeButton
-
Get the Home button (HomeButton) object.
-
readonlyimageryLayers : ImageryLayerCollection
-
Get the collection of image layers that will be rendered on Earth.
-
readonlyinfoBox : InfoBox
-
Get the InfoBox object.
-
readonlynavigationHelpButton : NavigationHelpButton
-
Get the navigation help button (NavigationHelpButton) object.
-
readonlyprojectionPicker : ProjectionPicker
-
Get the projection picker.
-
Gets or sets the scaling factor of the rendering resolution. Values less than 1.0 can improve performance on less powerful devices; conversely, values greater than 1.0 will be rendered at higher resolutions and then scaled down to improve visual fidelity. For example, if the widget is 640x480, setting this property to 0.5 will cause the scene to be rendered at 320x240 resolution, and the scene will be scaled up. Setting it to 2.0 will cause the scene to be rendered at 1280x960 and the scene scaled down.
-
Default Value:
1.0
-
readonlyscene : Scene
-
Get the scene object.
-
readonlysceneModePicker : SceneModePicker
-
Get the scene mode picker (SceneModePicker) object.
-
readonlyscreenSpaceEventHandler : ScreenSpaceEventHandler
-
Get the screen space event handler.
-
selectedEntity : Entity
-
Gets or sets the object instance for which the selection indicator is displayed.
-
readonlyselectedEntityChanged : Event
-
Gets the event raised when the selected entity object changes.
-
readonlyselectionIndicator : SelectionIndicator
-
Get the SelectionIndicator object.
-
readonlyshadowMap : ShadowMap
-
Get a shadow map of the scene.
-
Determine if the shadow is formed by the sun's projection.
-
Gets or sets the target frame rate of the component when useDefaultRenderLoop is set to true. If this property is not defined, the frame rate is determined by the browser's
requestAnimationFrame
implementation; if this property is already defined, the value should be greater than 0, and Values larger than the underlying requestAnimationFrame will not work. -
terrainProvider : TerrainProvider
-
A TerrainProvider object that provides surface geometry for the Earth.
-
terrainShadows : ShadowMode
-
Determine if the terrain projects or accepts shadows from the sun.
-
readonlytimeline : Timeline
-
Get the Timeline component.
-
trackedEntity : Entity
-
Gets or sets the entity instance currently being tracked by the camera.
-
readonlytrackedEntityChanged : Event
-
Gets the events raised when the tracking entity object changes.
-
Gets or sets whether the widget can control the render loop.
When set to true, the component will use requestAnimationFrame to perform rendering and resizing parts, as well as driving the clock emulation; When set to false, you must manually call the render and resize methods as part of a custom loop render.
If an error occurs during rendering, Scene's renderError event will be fired and this property will be changed to false. This property must be changed back to true after the error occurs in order to continue rendering. -
readonlyvrButton : VRButton
-
Get the VRButton object.
Methods
-
Release the resources occupied by the object.
-
Use the provided mixin to extend the underlying viewer functionality. Mixin can add additional properties, functionality, or other behavior to the provided viewer instance.
Name Type Description mixin
Viewer~ViewerMixin Specifies the Viewer mixin object that will be added to the instance. options
Object optional Specifies the options object passed to the mixin function. See:
-
The camera flies to the specified entity, entity set, or data source. If the data source is still loading, or if visualization is still in progress, this method waits for data to be ready before performing the flight.
The offset variable is represented by the "azimuth/pitch angle/range" in the local "east-north-up" reference frame (the center point is the center of the encircled ball). The angles of the azimuth and elevation angles are defined in the local "east-north-up" reference frame. Azimuth heading is the angular value that starts from the y-axis and increases toward the x-axis. The pitch angle pitch is the angle of rotation from the xy plane. The positive pitch angle is above the plane and the negative is below the plane. The distance range represents the distance from the center point. If range is 0, a range is calculated such that the entire bounding sphere is visible.
There must be a top-down view in 2D. The camera is located above the target. Range is the height above the target; headingy is determined by the offset. If the azimuth cannot be determined from the offset, heading is north.
Name Type Description target
Entity | Array.<Entity> | EntityCollection | DataSource | ImageryLayer | Promise.<(Entity|Array.<Entity>|EntityCollection|DataSource|ImageryLayer)> Specifies the entity, entity set, data source, or image layer to view. You can also specify a promise to resolve one of the aforementioned types. options
Object optional The object has the following properties: Name Type Default Description duration
Number 3.0
optional Flight duration (in seconds). maximumHeight
Number optional The maximum height in flight. offset
HeadingPitchRange optional In the local "east-north-up" reference frame centered on the target, the offset from the target. Returns:
When the flight is successful, the promise is parsed as true; if the entity is not visualized in the scene or the flight is canceled, the promise is parsed to false. -
Forced re-adjustment, so that the component reconsider the layout including component size, credit placement, and so on.
-
Returns whether to release the resources occupied by the object.
Returns:
True means that the occupied resource has been released, otherwise it returns false. -
Render the scene. This function is called automatically unless useDefaultRenderLoop is set to false.
-
Resize the part to match the container. This function will be called automatically on demand unless
useDefaultRenderLoop
is set to false. -
Set up the camera asynchronously to view the specified entity, entity set, or data source. If the data source is still loading, or if visualization is still in progress, this method waits for the data to be ready before performing the scaling.
The offset variable is represented by the "azimuth/pitch angle/range" in the local "east-north-up" reference frame (the center point is the center of the encircled ball). The angles of the azimuth and elevation angles are defined in the local "east-north-up" reference frame. Azimuth heading is the angular value that starts from the y-axis and increases toward the x-axis. The pitch angle pitch is the angle of rotation from the xy plane. The positive pitch angle is above the plane and the negative is below the plane. The distance range represents the distance from the center point. If range is 0, a range is calculated such that the entire bounding sphere is visible.
There must be a top-down view in 2D. The camera is located above the target. Range is the height above the target; heading has an offset determination, otherwise the azimuth cannot be determined from the offset, and heading is north.
Name Type Description target
Entity | Array.<Entity> | EntityCollection | DataSource | ImageryLayer | Promise.<(Entity|Array.<Entity>|EntityCollection|DataSource|ImageryLayer)> Specifies the entity, entity set, data source, or image layer to view. You can also specify a promise to resolve one of the aforementioned types. offset
HeadingPitchRange optional Specifies the offset from the center of the local East-North-Up reference frame. Returns:
When the scaling succeeds, the promise is parsed to true; if the entity is not visualized or zoomed out in the scene, the promise is resolved to false.
Type Definitions
-
Add a function for a Viewer instance with additional functionality.
Name Type Description viewer
Viewer Viewer instance object. options
Object The options object passed to the mixin function. See: