Below is a function that'll give you an approximate view of a
rectangle. It works quite well in the tests i've done - to be honest
it works a lot better than I expected given how rough the maths are :)
Anywayz, you feed it the lat/lngs of your rectangle and it passes you
back a KmlCamera object which you can pass to
GEPlugin.getView().setAbstractView() to set the current view.
Example webpage here:
http://www.tinyg.com/googlearthtest6.html
Code:
function createCameraFromRectangle(plugin, lat1, lng1, lat2, lng2) {
var r = 6378700;
var fov = 34;
var camera = ge.createCamera('');
camera.setLatitude((lat1 + lat2) / 2.0);
camera.setLongitude((lng1 + lng2) / 2.0);
camera.setHeading(0.0);
camera.setTilt(0.0);
var dy = Math.max(lat1, lat2) - Math.min(lat1, lat2);
var dx = Math.max(lng1, lng2) - Math.min(lng1, lng2);
var d = Math.max(dy, dx);
d = d * Math.PI / 180.0;
var dist = r * Math.tan(d / 2);
var alt = dist / (Math.tan( fov * Math.PI / 180.0));
camera.setAltitude(alt);
return camera;