title: How can I increase a GLatLngBounds (rectangle) by 10% in google maps API?
body: <p>I have a map with a bunch of points on it, and I want to zoom such that all points fit on the screen. The code for this is fairly simple:</p>
  
  <pre><code>var bounds = new GLatLngBounds();
  
  for (var n = 0; n &lt; points.length; n++) {
    bounds.extend(points[n].getLatLng());
  }
  
  zoomLevel = map.getBoundsZoomLevel(bounds);
  </code></pre>
  
  <p>to get the zoom level, you have to pass in a bounds object. To create a bounds object, you either give it two points like a rectangle, or you pass it a point and it increases in size (if necessary) to incorporate the point which is what I do above.</p>
  
  <p>The problem is that the points appear right on the edge of the screen. I'd like to increase the size of the bounds by say, 10%. I can get the two points out of my bounds object using <code>bounds.getNorthEast();</code> and <code>bounds.getSouthWest();</code> but to increase them by 10% of the size of the bounds is proving tricky. I tried <code>toSpan()</code> on the bounds which gives you a LatLng containing the size of the bounds, and then did 10% of the Lat and Lng and added it to my coordinates. However, it did not seem to work. My code for this attempt was:</p>
  
  <pre><code>var pointNorthEast = bounds.getNorthEast();
  var pointSouthWest = bounds.getSouthWest();
  
  var latAdjustment = ((pointNorthEast.lat() - pointSouthWest.lat()) * increasePercentage) / 2;
  var lngAdjustment = ((pointNorthEast.lng() - pointSouthWest.lng()) * increasePercentage) / 2;
  
  
  var newPointNorthEast = new GLatLng(pointNorthEast.lat() + latAdjustment, pointNorthEast.lng() + lngAdjustment);
  var newPointSouthWest = new GLatLng(pointSouthWest.lat() - latAdjustment, pointSouthWest.lng() - lngAdjustment);
  
  
  bounds = new GLatLngBounds();
  
  bounds.extend(newPointNorthEast);
  bounds.extend(newPointSouthWest);
  </code></pre>
  
  <p>By my reckoning, bounds should then be 10% bigger. I'm not certain it represents just a rectangle or stores any coordinate data or not so I didn't take chances by adding/subtracting half of the increase on each side to keep it centered.</p>
  
  <p>However, trying various increasePercentage values such as 1.1 or 1.5 it does not seem to make a difference.</p>
  
  <p>Therefore I've either cocked up my logic, my maths, or the fact that zoomLevel is not a smooth scale is hampering my attempts.</p>
  
  <p>I think I might have to just do <code>zoomLevel -= 1</code> and have done with it, but I wanted to see if anyone had any ideas first.</p>