new Cesium.BaseLayerPicker(container, options)

BaseLayerPicker
BaseLayerPicker with its drop-panel open.


BaseLayerPicker 是一个单一的按钮部件,显示一组可用的图像和 地形提供者。 当选择图像时, 创建并插入相应的图像层 作为图像收集的基层; 删除现有的基层。 当选择地形时, 它取代了当前地形提供者。 现有供应商名单上的每个项目都有一个名称, 具有代表性的图标和一个工具提示,用于显示盘旋时的更多信息。 名单最初是 空的,在使用前必须配置,如下示例所示.

默认情况下,BaseLayerPicker为演示目的使用默认的示例提供者列表. Notably some of these providers, such as Esri ArcGIS and Stadia Maps, have seperate terms of service and require authentication for production use.
Name Type Description
container Element | string 此部件的母 NT% 0 容器节点或ID .
options object 下列属性的对象 :
Name Type Default Description
globe Globe 环球报要使用.
imageryProviderViewModels Array.<ProviderViewModel> [] optional The array of ProviderViewModel instances to use for imagery.
selectedImageryProviderViewModel ProviderViewModel optional 使用目前底图图层的视图模型,如果不提供第一个可用的图层.
terrainProviderViewModels Array.<ProviderViewModel> [] optional The array of ProviderViewModel instances to use for terrain.
selectedTerrainProviderViewModel ProviderViewModel optional 目前基底地形层的视图模型,如果不提供第一个可用的地形层则被使用.
Throws:
  • DeveloperError : Element with id "container" does not exist in the document.
Example:
// In HTML head, include a link to the BaseLayerPicker.css stylesheet,
// and in the body, include: <div id="baseLayerPickerContainer"
//   style="position:absolute;top:24px;right:24px;width:38px;height:38px;"></div>

//Create the list of available providers we would like the user to select from.
//This example uses 3, OpenStreetMap, The Black Marble, and a single, non-streaming world image.
const imageryViewModels = [];
imageryViewModels.push(new Cesium.ProviderViewModel({
     name: "Open\u00adStreet\u00adMap",
     iconUrl: Cesium.buildModuleUrl("Widgets/Images/ImageryProviders/openStreetMap.png"),
     tooltip: "OpenStreetMap (OSM) is a collaborative project to create a free editable \
map of the world.\nhttp://www.openstreetmap.org",
     creationFunction: function() {
         return new Cesium.OpenStreetMapImageryProvider({
             url: "https://tile.openstreetmap.org/"
         });
     }
 }));

 imageryViewModels.push(new Cesium.ProviderViewModel({
     name: "Earth at Night",
     iconUrl: Cesium.buildModuleUrl("Widgets/Images/ImageryProviders/blackMarble.png"),
     tooltip: "The lights of cities and villages trace the outlines of civilization \
in this global view of the Earth at night as seen by NASA/NOAA's Suomi NPP satellite.",
     creationFunction: function() {
         return Cesium.IonImageryProvider.fromAssetId(3812);
     }
 }));

 imageryViewModels.push(new Cesium.ProviderViewModel({
     name: "Natural Earth\u00a0II",
     iconUrl: Cesium.buildModuleUrl("Widgets/Images/ImageryProviders/naturalEarthII.png"),
     tooltip: "Natural Earth II, darkened for contrast.\nhttp://www.naturalearthdata.com/",
     creationFunction: function() {
         return Cesium.TileMapServiceImageryProvider.fromUrl(
             Cesium.buildModuleUrl("Assets/Textures/NaturalEarthII")
         );
     }
 }));

//Create a CesiumWidget without imagery, if you haven't already done so.
const cesiumWidget = new Cesium.CesiumWidget("cesiumContainer", { baseLayer: false });

//Finally, create the baseLayerPicker widget using our view models.
const layers = cesiumWidget.imageryLayers;
const baseLayerPicker = new Cesium.BaseLayerPicker("baseLayerPickerContainer", {
    globe: cesiumWidget.scene.globe,
    imageryProviderViewModels: imageryViewModels
});
See:

Members

container : Element

得到母容器.
获得观音模型.

Methods

destroy()

摧毁部件。 如果永久调用, 应该调用 从布局中删除部件 .

isDestroyed()boolean

Returns:
如果物体已被销毁, 则真实无误 .
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.