# camera.flyTo move to unexpected position

**URL:** <https://community.cesium.com/t/camera-flyto-move-to-unexpected-position/6211>\
**Category:** CesiumJS\
**Created:** [November 1, 2017, 10:25pm UTC](https://community.cesium.com/t/camera-flyto-move-to-unexpected-position/6211 "2017-11-01T22:25:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![11137](https://avatars.discourse-cdn.com/v4/letter/1/c6cbf5/32.png) [@11137](https://community.cesium.com/u/11137)\
**Post date:** [November 1, 2017, 10:25pm UTC](https://community.cesium.com/t/camera-flyto-move-to-unexpected-position/6211/1 "2017-11-01T22:25:52Z")

</div>

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

function moveTo() {  
&nbsp;&nbsp;var result = document.getElementById('placeSelected');  
&nbsp;&nbsp;var entity = ds.getById(result.value);  
&nbsp;&nbsp;var position = entity.position.\_value;  
&nbsp;&nbsp;viewer.camera.flyTo({destination : {x : position.x, y : position.y, z : 4000.0}});  
&nbsp;&nbsp;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.

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [November 3, 2017, 7:50pm UTC](https://community.cesium.com/t/camera-flyto-move-to-unexpected-position/6211/2 "2017-11-03T19:50:28Z")

</div>

Hi there.

[Camera.flyTo](https://cesiumjs.org/Cesium/Build/Documentation/Camera.html#flyTo) isn’t instantaneous unless you set the duration to 0.0. Here’s our [Camera Tutorial](https://cesiumjs.org/tutorials/Camera-Tutorial/) if you need some additional info.

Thanks,

Gabby

---

<div class="post-metadata">

**Author:** ![11137](https://avatars.discourse-cdn.com/v4/letter/1/c6cbf5/32.png) [@11137](https://community.cesium.com/u/11137)\
**Post date:** [November 4, 2017, 4:35am UTC](https://community.cesium.com/t/camera-flyto-move-to-unexpected-position/6211/3 "2017-11-04T04:35:20Z")

</div>

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](https://global.discourse-cdn.com/cesium/original/2X/9/9194e93b2e685f58eefb723ee901d7a4a63d6ee2.png)

---

<div class="post-metadata">

**Author:** ![11137](https://avatars.discourse-cdn.com/v4/letter/1/c6cbf5/32.png) [@11137](https://community.cesium.com/u/11137)\
**Post date:** [November 4, 2017, 9:51am UTC](https://community.cesium.com/t/camera-flyto-move-to-unexpected-position/6211/4 "2017-11-04T09:51:09Z")

</div>

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](https://global.discourse-cdn.com/cesium/original/2X/9/9194e93b2e685f58eefb723ee901d7a4a63d6ee2.png)

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [November 6, 2017, 10:36pm UTC](https://community.cesium.com/t/camera-flyto-move-to-unexpected-position/6211/5 "2017-11-06T22:36:21Z")

</div>

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

![snapShot.PNG](https://global.discourse-cdn.com/cesium/original/2X/9/9194e93b2e685f58eefb723ee901d7a4a63d6ee2.png)
