Screen Coordinates

Hello!

I need to know what is the upper-left and the lower-right coordinates on the map of the screen (or upper-right and lower-left). I want to save the coordinates to view an extend in future.

I know I can save and load camera properties. But I need the longitude/ latitude values.

How can I do that?

Thanks!

Hi Tamy,

Do you need the extent that is visible from the camera? Do you need it for a specific mode or all three? Calculating the visible extent will be different in all three modes.

Dan

Hi Dan,

I need the extent of what I’m seeing at the moment on the screen. I need for 2D and 3D modes.
Thanks!

Tamy

Hi!

How can I calculate the visible extent from camera in 2D and 3D??

Thanks!

I don’t think it’s a simple thing to do, but I think it’s a common enough request that we should have support for it out of the box. I’ve created Github issue #871 for it.

I solved my problem:

function getExtentView(){

var c2 = new Cesium.Cartesian2(0,0);

var leftTop = scene.getCamera().controller.pickEllipsoid(c2, ellipsoid);

c2 = new Cesium.Cartesian2(scene.getCanvas().width, scene.getCanvas().height);

var rightDown = scene.getCamera().controller.pickEllipsoid(c2, ellipsoid);

if(leftTop != null && rightDown != null){

leftTop = ellipsoid.cartesianToCartographic(leftTop);

rightDown = ellipsoid.cartesianToCartographic(rightDown);

return new Cesium.Extent(leftTop.longitude, rightDown.latitude, rightDown.longitude, leftTop.latitude);

}else{//The sky is visible in 3D

return null;

}

}

Thanks for posting this Tamy. This was helpful to me as well. I'm sure this is the holy grail, but has anyone come up with a good solution to the "sky is visible" problem?

Just thinking out loud here… Couldn’t we set the camera as a sensor (I remember there was some sensor library in the past), calculate the intersection of the sensor with the geoid and get the bounds of that shape? would that work?