我正在尝试使用以下代码将 distanceDisplayCondition 参数添加到由 CZML 格式描述的走廊中:
var czml = [{
"id" : "document",
"name" : "CZML Geometries: Polyline",
"version" : "1.0"
}, {
"id" : "redCorridor",
"name" : "Red corridor on surface with rounded corners",
"corridor" : {
"positions" : {
"cartographicDegrees" : [
-122.19, 46.1914, 0,
-122.21, 46.21, 0,
-122.23, 46.21, 0
]
},
"distanceDisplayCondition": [1,1000],
"heightReference": "CLAMP_TO_GROUND",
"width" : 200.0,
"material" : {
"solidColor" : {
"color" : {
"rgba" : [255, 0, 0, 127]
}
}
}
}
}];
var viewer = new Cesium.Viewer('cesiumContainer', { terrainProvider: Cesium.createWorldTerrain() });
var dataSourcePromise = Cesium.CzmlDataSource.load(czml);
viewer.dataSources.add(dataSourcePromise);
viewer.zoomTo(dataSourcePromise);
不幸的是,我意识到这个选项不能通过 CZML 格式工作,我的一个同事用下面的代码做了一个 JS 实体的例子:
var viewer = new Cesium.Viewer('cesiumContainer');
var redCorridor = viewer.entities.add({
name : 'Red corridor on surface with rounded corners',
corridor : {
positions : Cesium.Cartesian3.fromDegreesArray([
-100.0, 40.0,
-105.0, 40.0,
-105.0, 35.0
]),
width : 200000.0,
material : Cesium.Color.RED.withAlpha(0.5),
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 3000000)
}
});
viewer.zoomTo(viewer.entities);
似乎 JS 实体方式正在工作。它是一个错误吗?或者我没有正确使用 distanceDisplayCondition 选项?