Search code examples
google-earth-plugin

Is there any built-in functions in Google Earth API to calculate the least camera range needed to show whole geoobject?


For example, I have a line with 3 points:
lat / lon
56,1 / 46,1
56,2 / 46,2
56,3 / 46,3

If I do:

var lookAt = ge.createLookAt('');
lookAt.setLatitude(56.2);
lookAt.setLongitude(46.2);
lookAt.setRange(5000.0);

For sure i will see all line, but from too far
If I do:

lookAt.setRange(10.0);

I will see only middle line point, so... Is there any way to calculate the least needed range to see whole line?


Solution

  • Try using the GEarthExtensions library script. In particular - computeBounds()

    You can see an example of it here

    http://earth-api-utility-library.googlecode.com/svn/trunk/extensions/examples/bounds-view.html