title: How does this Google Maps zoom level calculation work?
body: <p>I know what the input and outputs are, but I'm just not sure how or why it works.</p>
  
  <p>This code is being used to, given a min and max longitude/latitude (a square) that contains a set of points, determine the maximum zoom level on Google Maps that will still display all of those points.  The original author is gone, so I'm not sure what some of these numbers are even for (i.e. 6371 and 8).  Consider it a puzzle =D</p>
  
  <pre><code>int mapdisplay = 322; //min of height and width of element which contains the map
  double dist = (6371 * Math.acos(Math.sin(min_lat / 57.2958) * Math.sin(max_lat / 57.2958) + 
              (Math.cos(min_lat / 57.2958) * Math.cos(max_lat / 57.2958) * Math.cos((max_lon / 57.2958) - (min_lon / 57.2958)))));
  
  double zoom = Math.floor(8 - Math.log(1.6446 * dist / Math.sqrt(2 * (mapdisplay * mapdisplay))) / Math.log (2));
  
  if(numPoints == 1 || ((min_lat == max_lat)&amp;&amp;(min_lon == max_lon))){
      zoom = 11;
  }
  </code></pre>