Camera move X pixels

Hello i would like to Flyto a position - this works fine, the position is in the center of the map
And now i would like to pan the map in such a way that the position, which was in the center now moves to the PIXEL position 500, 50.

I found i can move them camera with moveLeft and so anmount meters, but i dno’t know how i can calc how much meter 500 pixels are?

anybody can help?


You can convert the pixel coordinate to a coordinate in world space using picking. You can get the globe position using var cartesian = Cesium.Cartesian2(500, 50)), scene.globe.ellipsoid);

and use that value for the destination of the flight.



Hmmm i just tried it
var dest = Cesium.Cartesian2(500, 50), viewer.scene.globe.ellipsoid);


dest.z =;



But it didn’t do what i want, is there something wrong with my code?

The code looks fine. If that’s not the behavior you want, than I think I misunderstood what you’re trying to do. Can you please elaborate?


Hannah, imagine you wanna move the position of the camera x pixels right, say, for displaying a custom popup on screen if it popups half-way off-screen.
What would be the way?

Just wanna get current camera position and add x pixels to the right!

@dsldiesel can you share a Sandcastle showing the issue? See: How to share custom Sandcastle examples

It’d be helpful to see what the current suggested approach does vs what the expected one is.

Thanks Omar;
It’d take long to adapt my modern vue.js app code to a sandcastle, sorry.
I’ll paste an image so you can see my issue, I have made a wms service callback function that processes the data and shows a custom popup (didn’t find any native cesium popup functionality, pls let me know if there is one). This popup may pop off-screen as in image. If so, the camera should animate, or flyto, a few pixels to the right so the popup is again on-screen.

Other tools like leaflet have popup function built-in, and this behavior is implemented already inside the library. I am doing all this and could not find an easy way to move the map right smoothly, and am stuck with something like this:

if ((viewer.scene.canvas.width - e.position.x) < 250) {
    // do stuff considering e is click event and 250px is popup's width

If you can detect when the popup is offscreen, could you just fly the camera such that the entity of the popup is in the center of the screen?

Hi Omar!

Thanks, but that is exactly what I am trying to do.
My way to recognise an ‘out-of-screen’ popup is as follows (considering 250px is the outer width of popup and e.position is cursor click):

if ((viewer.scene.canvas.width - e.position.x) < 250)

But I am pretty lost after it, as I am new to Cesium.
Could you illuminate that camera fly?
I am stuck here now, THIS IS NOT WORKING:

const canvas = viewer.scene.canvas;
const center = new Cesium.Cartesian2(canvas.clientWidth / 2.0, canvas.clientHeight / 2.0);
center.x += 250;
const result =, viewer.scene.globe.ellipsoid);{ destination : result });