1

I am trying to add distanceDisplayCondition parameters into a corridor described by CZML format with the code below:

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);

unfortunately I realized that this option is not working through CZML format, a colleague of mine made an example with a JS entity with the code below:

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);

and it seems that the JS entity way is working. Is it a bug? or I do not use the distanceDisplayCondition option properly?

chatzich
  • 1,083
  • 2
  • 11
  • 26

1 Answers1

1

I need to change:

"distanceDisplayCondition": [1, 1000]

To:

"distanceDisplayCondition": {
            "distanceDisplayCondition": [1, 1000]
        },
chatzich
  • 1,083
  • 2
  • 11
  • 26
  • And note for those not using CZML but adding it as a JS object (similar), you would do `distanceDisplayCondition: new Cesium.DistanceDisplayCondition(1.0, 1000.0)` – Andrew Dec 21 '20 at 20:38