title: Calculate range and altitude of the Google Earth KML LookAt element to fit all features (polygons)
body: <p>I have several polygons drawn on the surface in google earth plugin. I generate a KML from them.</p>
  
  <p>Question is how can I calculate parameters for the LookAt so that the view includes all the polygons when open in the desktop Google Earth?
  For lat and lon it's quite simple - just calculate the center of bounding box, but what about altitude and range parameters?</p>
  
  <p>For example we have two polygons:</p>
  
  <pre><code>1:
      40.724536 -74.001914
      40.724102 -74.001091
      40.723003 -74.002067
      40.723392 -74.002891
  2:
      40.723186 -74.003112
      40.722843 -74.002311
      40.721977 -74.003036
      40.722320 -74.003738
  </code></pre>
  
  <p>Then lon and lat will be<br>
  lon=(40.724536+40.721977)/2=40.7232565<br>
  lat=-(74.001091+74.003738)/2=-74.0024145</p>
  
  <p>Now how to calculate the range and altitude?</p>