camera.flyTo move to unexpected position

viewer.camera.flyTo() move to unexpected position in code below.

function moveTo() {
  var result = document.getElementById('placeSelected');
  var entity = ds.getById(result.value);
  var position = entity.position._value;
  viewer.camera.flyTo({destination : {x : position.x, y : position.y, z : 4000.0}});
  result.value = "";
}

Chrome Developer Tools show next.

position
a {x: -3944585.312596666, y: 3354701.5667262836, z: 3711337.4542463096}
viewer.camera.position
a {x: -4858315.3833287945, y: 4132480.0609128857, z: 4934.821065525686}

Please tell me something is wrong.

Hi there.

Camera.flyTo isn’t instantaneous unless you set the duration to 0.0. Here’s our Camera Tutorial if you need some additional info.

Thanks,

Gabby

Thank you Gabby.

I modifed code with your advice. As result, camera.positon meets positon I gave.

function moveTo() {

var result = document.getElementById(‘placeSelected’);

var entity = borling.getById(result.value);

var position = entity.position._value;

viewer.camera.flyTo({

destination : {x : position.x, y : position.y, z : 4000.0},

duration : 0.0}); // add duration

result.value = “”;

}

But, The screen becomes pure white like the snapshot below.

Is there any solution ?

snapShot.PNG

I changed the method flyTo() to lookAt() and solved it.

function moveTo() {

var result = document.getElementById(‘placeSelected’);

var entity = borling.getById(result.value);

var center = entity.position._value;

viewer.camera.lookAt(center, new Cesium.Cartesian3(0, 0, 400));

/*

viewer.camera.flyTo({

destination : {x : center.x, y : center.y, z : center.z + 400},

duration : 0.0});

*/

result.value = “”;

}

snapShot.PNG

Got it, glad you could fix it. Thanks for the update!

snapShot.PNG