Uncaught TypeError: Cesium.DistanceDisplayCondition is not a constructor

1. A concise explanation of the problem you’re experiencing.

I am developing an MVC app and am getting this Uncaught TypeError error when I add: distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 6000000)

to my labels.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

This is from the javascript file the cshtml page references:

Geocodes.forEach(element => {
position: new Cesium.Cartesian3.fromDegrees(element[0], element[1], 1000),
point: {
pixelSize: 10,
color: Cesium.Color.BLUE,
outlineColor: Cesium.Color.WHITE,
outlineWidth: 3
label: {
id: element[3],
text: element[2],
font: ‘20pt monospace’,
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
outlineColor: Cesium.Color.BLACK,
outlineWidth: 2,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 6000000)

If I comment out the distanceDisplayCondition, everything works as intended. If I leave it like this, Chrome throws the error: Uncaught TypeError: Cesium.DistanceDisplayCondition is not a constructor

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

I only want to labels to show when I zoom in on them. I am zooming in on different parts of the globe and leaving it on a loop, I only want the labels to show when it is their turn.

4. The Cesium version you’re using, your operating system and browser.

I pulled the code from https://github.com/jumpinjackie/cesium-dotnet-examples/tree/master/CesiumAspNetDemo/Views/Demo. I made some adjustments to the html and javascript files. Using an MSI laptop (powerful) and am getting errors in Chrome, Firefox and Edge.


SCRIPT445: SCRIPT445: Object doesn’t support this action
TypeError: Cesium.DistanceDisplayCondition is not a constructor[Learn More]


test.js:81 Uncaught TypeError: Cesium.DistanceDisplayCondition is not a constructor

Looking at the repo, it looks like they’re using an old version of Cesium (from 2015):


That property was added to Billboards in 2016 (in this commit I believe).

Try updating the Cesium.js file. You can find the latest version here:

This should fix it.

You were spot on with that. New Cesium.js file and adjusted the .css files required. Everything working as intended!