BaseLayerPicker 的下拉面板展开状态。
BaseLayerPicker 是一个单按钮控件,显示一个包含可用影像和地形提供者的面板。选择影像时,会创建相应的影像图层并作为影像集合的基础图层插入,同时移除现有的基础图层。选择地形时,会替换当前的地形提供者。可用提供者列表中的每一项包含名称、代表性图标和悬停时显示更多信息的工具提示。该列表初始为空,使用前必须进行配置,如下例所示。
默认情况下,BaseLayerPicker 使用一组示例提供者列表用于演示目的。需要注意的是,其中一些提供者(如 Esri ArcGIS 和 Stadia Maps)有单独的服务条款,并在生产使用时需要身份验证。
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
container |
Element | string | 此控件的父 HTML 容器节点或 ID。 | ||||||||||||||||||||||||
options |
object |
具有以下属性的对象:
|
Throws:
-
DeveloperError : 文档中不存在 id 为 "container" 的元素。
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
获取父容器。
获取视图模型。
Methods
销毁控件。如果永久移除布局中的控件,应调用此方法。
Returns:
如果对象已被销毁则返回 true,否则返回 false。
