title: Saving coordinates and data from Google maps in a database
body: <p>I am making a map project where when I choose an area (with google maps drawing tools) an info window pops up and I can write a Name and a Description and then save these and its coordinates. I am using a POST form and to this moment I am able to save in my DB the Name and Description but I cant find a way to save the coordinates. I have already tried with no success to pass it through POST or put some PHP in my JS. 
  Here is my js code for the rectangle drawing tool:</p>
  
  <pre><code>google.maps.event.addListener(drawingManager, 'rectanglecomplete', function(rectangle) {
  
      var ne = rectangle.getBounds().getNorthEast();
      var sw = rectangle.getBounds().getSouthWest();
      var nelat = ne.lat();
      var nelng = ne.lng();
      var swlat = sw.lat();
      var swlng = sw.lng();
      var coordsrec = ';' + nelat.toFixed(6) + ';' + nelng.toFixed(6)+ ';' + swlat.toFixed(6) + ';' + swlng.toFixed(6);
      //console.log(coordsrec);
  
      contentsr = '&lt;form action="SaveData.php" method="POST"&gt;&lt;b&gt;Region Name : &lt;/b&gt;&lt;br/&gt;&lt;input type="text" size="20" name="region_name"/&gt;&lt;input type="hidden" name="region_type" value="2"&gt;&lt;br/&gt;&lt;b&gt;Description : &lt;/b&gt;&lt;br/&gt;&lt;textarea name="region_desc" cols="20" rows="3"&gt;&lt;/textarea&gt;&lt;br/&gt;&lt;center&gt;&lt;br/&gt;&lt;input type="submit" value="Save Region" name="save_region"&gt;&lt;/center&gt;&lt;/form&gt;'; 
  
      var boundsr = new google.maps.LatLng(ne.lat(), ne.lng());
  
      infoWindow.setContent(contentsr);
      infoWindow.setPosition(boundsr); 
      drawingManager.setDrawingMode(null);
      infoWindow.open(map);
  });
  </code></pre>
  
  <p>I tried sending the coordinates as a hidden field but I can't make it work. </p>
  
  <p>I tried it like this:</p>
  
  <pre><code>&lt;input type="hidden" name="coords" id="coords" value="coordsrec"&gt;
  </code></pre>
  
  <p>but it saves it as the word "coordsrec" in the DB. </p>
  
  <p>I also tried:</p>
  
  <pre><code>&lt;input type="hidden" name="coords" id="coords" value="&lt;?php echo $coordsrec; ?&gt;"&gt; 
  </code></pre>
  
  <p>or added the line:</p>
  
  <pre><code>document.getElementById("coords").value = coordsrec; . 
  </code></pre>