title: Center of Polygon Google Maps JavaScript API v3
body: <p>I looked through this thread: <a href="https://stackoverflow.com/questions/3081021/how-to-get-the-center-of-a-polygon-in-google-maps-v3/13772082#13772082">How to get the center of a polygon in google maps v3?</a>, and <em>Matthew Scharley's</em> answer currently marked as correct does not do it for me. I am downloading corner coordinates for 50-100 polygons dynamically from the server in an array of lat/long objects, and I need a dynamic not manual solution for determining polygon centers. The answer from the same thread by <em>furiozo</em> comes close to fulfilling my needs, as it calculates the average center of the polygon, but the results that I see in my console.log from his function:</p>
  
  <pre><code>google.maps.Polygon.prototype.my_getBounds=function(){
      var bounds = new google.maps.LatLngBounds()
      this.getPath().forEach(function(element,index){bounds.extend(element)})
      return bounds
  }
  
  console.log(myPolygon.my_getBounds().getCenter());
  </code></pre>
  
  <p>are not something that I can readily use in my program. </p>
  
  <p>What I get in the console is this: </p>
  
  <pre><code>_.M {}
     lat: function ()
        arguments: (...)
        caller: (...)
        length: 0
        name: ""
        prototype: Object
        __proto__: function ()
        &lt;function scope&gt;
          Closure
            a: 45.256705626
            b: -75.91270512
          Closure 
          Global: Window
     lng: function() -- contains same sub-levels as lat: function() --
     __proto__: Object
  </code></pre>
  
  <p>What I really need right now is how to get to the a &amp; b lat/lng values that sit under the first Closure level in  in lat: function() in the object I'm getting in my console. (I have checked manually by substituting these results in code, they represent the correct center for the first of my polygons). Any help with how to get to them will be greatly appreciated. </p>
  
  <p>Or, if anybody knows of any up-to-date solution for how to get average polygon center coordinate values dynamically so that the end result will be in the format of (lat, lng), this may save my day.</p>
  
  <p>Thank you very much!</p>