title: Google Maps API V3 - building catchment area variable
body: <p>I'm trying to make a program that builds up a boundary area on Google Maps API v3 from given points stored in a database. I made this work in PHP however couldn't run checks to see if a point is within the bounds or not.</p>
  
  <p>I've re-created it in JavaScript however I've hit a wall with showing the points. I've pulled the points back in and there echoed as a a JS variable:</p>
  
  <pre><code>Example:
  var boundArray =  ["52.6,1.19","52.7,1.20","52.7,1.19","52.6,1.20"];
  </code></pre>
  
  <p>I'm trying to run through the array and build up the 'path' attribute for the polygon however it wont allow me to run a for loop within the array and I cannot construct this in an alternative method.</p>
  
  <pre><code>function grabPoints() {
      var catchmentCoords = [
          for(var i=0; i&lt;(boundArray.length-1); i++){
              new google.maps.LatLng(boundArray[$i]),
          }
          new google.maps.LatLng(boundArray[boundArray.length])
      ];
  }
  </code></pre>
  
  <p>The function above <em>should</em> build a list of points in the variable as shown below which is used to show all points at once.</p>
  
  <pre><code>var catchmentCoords = [
      new google.maps.LatLng(52.6,1.19),
      new google.maps.LatLng(52.7,1.20),
      new google.maps.LatLng(52.7,1.19),
      new google.maps.LatLng(52.6,1.20)
  ];
  </code></pre>
  
  <p>If it helps the attribute is intended to be used within the polygon function for the API.</p>
  
  <pre><code>catchmentArea = new google.maps.Polygon({
      paths: catchmentCoords
  });
  </code></pre>
  
  <p>Additionally if there is a nicer way to search if a lat/long is inside a polygon this would be appreciated.</p>