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?

Hello,

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

and use that value for the destination of the flight.

Best,

Hannah

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

console.log(dest);

dest.z = viewer.camera.position.z;

console.log(dest);

viewer.camera.flyTo({destination:dest});

``

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

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?
Thanks

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