Moving labels

I tried moving labels by altering the ._position property, but it crashes. Is there a way to dynamically move labels? Here’s a SandCastle attempt:
var viewer = new Cesium.Viewer(‘cesiumContainer’);

var myLabel=viewer.entities.add


position : new Cesium.Cartesian3(0,-7e6,0)

,point : {pixelSize : 5}

,label : {text : ‘test’ }


var CC3=Cesium.Cartesian3;

setTimeout(function(){ myLabel._position = new CC3(0,-8e6,0);}, 3000);

setTimeout(function(){ myLabel._position = new CC3(0,-9e6,0);}, 6000);


Is there a reason why you are using _position to change to position? You can change the position of myLabel with no crashes:

myLabel.position = Cesium.Cartesian3(0,-8e6,0);


myLabel.position = new Cesium.Cartesian3(0,-8e6,0);

I saw ._position in which is why I tried that. I think I did try .position initially but it probably failed for another reason that I’ve since corrected. Thanks for pointing that out!

In general, never read or write properties that start with an underscore, JavaScript objects have no concept of private members and _ is used by convention is almost all JavaScript APIs to indicate it.

Thanks, I’ll keep that in mind. I should probably change all of my

references to


as well. Or is there a camera.positionCartographic.height property that’s constantly updated? I gotta check.

There’s a camera.positionCartographic property (no underscore). Access _positionCartographic will actually give you the wrong answer under certain circumstances, using the public property will ensure it is always correct.

While console logging will work, I would recommend using the reference documentation, since that’s the entire reason it exists:

non-underscored items explicitly marked @private will show up in console.log but not show up in the documentation.

Thanks for the info! I suppose a good way to determine what is available is doing something like console.log(; which yields a list of all the properties. Just avoid using the ones preceded by an underscore.

Perhaps even without an underscore some may not be intended to be used by functions outside of that file? Just try to stick with the ones mentioned in the docs I suppose.

I see what you mean, some examples I noticed as marked private: Camera.prototype.update, Camera.prototype.createCorrectPositionTween . Some of them even have documentation in the js file, but still marked private so they don’t show up on the extracted reference documentation., only intended to be used internally.