Update coordinates of a loaded entity


i have to upadate the hierarchy of un entity correctly loaded on Cesium.

This is what i do:

cartesianCoordinates = Cesium.Cartesian3.fromDegrees(lon, lat);

selectedEntity.polygon.hierarchy._value.positions[0] = new Cesium.Cartesian3(cartesianCoordinates.x, cartesianCoordinates.y, cartesianCoordinates.z);


lat and lon contain for example 10 degrees.

On debug mode all seems work. The selected entity have changed but the boundary of the entity don’t change on the entity displays.

Any suggestions?


Hello Gianmaria,

As a general rule, you shouldn’t access private variables from our objects because they might have unexpected behavior. A private variable is anything that starts with an underscore, like “_value”.

Instead, to get the value from the hierarchy (or any other Entity property) you can use hierarchy.getValue(currentTime)

Here is an example that changes the polygon positions on left click:

var viewer = new Cesium.Viewer(‘cesiumContainer’, {
selectionIndicator : false,
infoBox : false

var scene = viewer.scene;

var entity = viewer.entities.add({
polygon : {
hierarchy : Cesium.Cartesian3.fromDegreesArray([-115.0, 37.0,
-115.0, 32.0,
-107.0, 33.0,
-102.0, 31.0,
-102.0, 35.0]),
material : Cesium.Color.RED

var handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(click) {
var pickedObject = scene.pick(click.position);
if (Cesium.defined(pickedObject) && (pickedObject.id === entity)) {
var positions = entity.polygon.hierarchy.getValue(viewer.clock.currentTime);
positions[0] = Cesium.Cartesian3.fromDegrees(-110.0, 37.0);
entity.polygon.hierarchy = positions;
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);




This is what i try to do following your code:

var positions = selectedEntity.polygon.hierarchy.getValue(viewer.clock.currentTime).positions;
var a = 0;
positions[a] = Cesium.Cartesian3.fromDegrees(lon, lat);
selectedEntity.polygon.hierarchy.getValue(viewer.clock.currentTime).positions = positions;


At now my changes are saved but the figure displayed on Cesium doesn’t change.

Maybe i have to do something similar to a refresh?

I solve the problem with this two lines: