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?
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.
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
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
}
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.camera.pickEllipsoid(center, viewer.scene.globe.ellipsoid);
viewer.camera.flyTo({ destination : result });