# Camera.computeViewRectangle give false rectangle in australia

**URL:** <https://community.cesium.com/t/camera-computeviewrectangle-give-false-rectangle-in-australia/5185>\
**Category:** CesiumJS\
**Created:** [February 19, 2017, 5:18pm UTC](https://community.cesium.com/t/camera-computeviewrectangle-give-false-rectangle-in-australia/5185 "2017-02-19T17:18:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Esra\_ERIK](https://avatars.discourse-cdn.com/v4/letter/e/cdc98d/32.png) [@Esra\_ERIK](https://community.cesium.com/u/Esra_ERIK)\
**Post date:** [February 19, 2017, 5:18pm UTC](https://community.cesium.com/t/camera-computeviewrectangle-give-false-rectangle-in-australia/5185/1 "2017-02-19T17:18:58Z")

</div>

Hello,  
I’m using camera computeViewRectangle method.It run properly nearly everywhere. But When I’m looking to avustralia (or near locations )and save cameraviewrectangle and later when I try to fly to this rectangle with it fly to other region like africa.

I’m modified viewRectangle sandcastle to show faulty result .

function viewRectangle() {

Sandcastle.declare(viewRectangle);

var west = -3.1415926;

var south =-1.57079;

var east = 3.1415926;

var north = 1.57079;

var rect=scene.camera.computeViewRectangle(viewer.scene.globe.ellipsoid);

var rectangle = Cesium.Rectangle.fromDegrees(west, south, east, north);

viewer.camera.flyTo({

destination: rect,

duration:3

});

console.log(rect);

// Show the rectangle. Not required; just for show.

viewer.entities.add({

rectangle : {

coordinates : rect,

fill : false,

outline : true,

outlineColor : Cesium.Color.WHITE

}

});

}

If you are try view rectangle choice when looking australia. You can see faulty result and faulty rectangle drawwing.

This error can be solve. Is it a bug or my fault.

Thanks .

Esra ERİK

---

<div class="post-metadata">

**Author:** ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)\
**Post date:** [February 20, 2017, 1:37pm UTC](https://community.cesium.com/t/camera-computeviewrectangle-give-false-rectangle-in-australia/5185/2 "2017-02-20T13:37:55Z")

</div>

Hello,

I wasn’t able to reproduce the error you were seeing. Here is the example I tested with:

var viewer = new Cesium.Viewer(‘cesiumContainer’);  
var west = -3.1415926;  
var south =-1.57079;  
var east = 3.1415926;  
var north = 1.57079;

function callback() {  
return new Cesium.Rectangle(west, south, east, north);  
}

Sandcastle.addToolbarButton(‘Save’, function() {  
var rect = viewer.scene.camera.computeViewRectangle();  
west = rect.west;  
south = rect.south;  
east = rect.east;  
north = rect.north;  
});

Sandcastle.addToolbarButton(‘Load’, function() {  
viewer.camera.flyTo({  
destination: new Cesium.Rectangle(west, south, east, north)  
});  
});

viewer.entities.add({  
rectangle : {  
coordinates : new Cesium.CallbackProperty(callback, false),  
fill : false,  
outline : true,  
outlineColor : Cesium.Color.WHITE  
}  
});

``

Make sure you are using the latest version of Cesium. I know at one point we had a bug where computeViewRectangle wasn’t working correctly in the southern hemisphere.

For saving and loading the camera position, I would recommend the method described in this forum post instead: [https://groups.google.com/d/msg/cesium-dev/lolHXdDitOg/GC4iPNiICgAJ](https://groups.google.com/d/msg/cesium-dev/lolHXdDitOg/GC4iPNiICgAJ)

computeViewRectangle isn’t the most accurate for certain tilted and zoomed out views. Saving the position/heading/pitch/roll will give you better results.

Best,

Hannah
