title: How do I use Google Maps geocoder.getLatLng() and store its result in a database?
body: <p>Hey everybody! Im trying to use getLatLng() to geocode a list of postal/zip codes and store the generated point in the database to be placed on a map later. This is what I've got so far:</p>
  
  <pre><code> $(".geocodethis").click(function () {
      var geocoder = new GClientGeocoder();
      var postalCode = $(this).siblings(".postal").val();
      var id = $(this).siblings(".id").val();
  
      geocoder.getLatLng(postalCode, function (point) {
          if (!point) {
              alert(postalCode + " not found");
          } else {
              alert(point);
              var serializedPoint = $.param(point);                
              //Geocode(id, point);
          }
      });
  
  });
  
  function Geocode(id, point) {
      alert(point);
      $.post("/Demographic/Geocode/" + id, point, function () {
          alert("success?");
      });
  }
  </code></pre>
  
  <p>but I'm getting <code>this.lat is not a function</code> in my error console when i try to serialize the point object or use it in <code>$.post()</code></p>
  
  <p>From my research, I understand that <code>geocoder.getLatLng()</code> is asynchronous, how would that affect what I'm trying to do? I'm not running this code in a loop, and I'm trying to post the point using the anonymous callback function.</p>
  
  <p>How can I save the information from <code>point</code> to use later?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Creating a marker and trying to post that still results in the <code>this.lat is not a function</code>  in the error console.</p>
  
  <pre><code>$(".geocodethis").click(function () {
          var geocoder = new GClientGeocoder();
          var postalCode = $(this).siblings(".postal").val();
          var id = $(this).siblings(".id").val();
  
          geocoder.getLatLng(postalCode, function (point) {
              if (!point) {
                  alert(postalCode + " not found");
              } else {
                  alert(point);
                  var marker = new GMarker(point);
  
                  $.post("/Demographic/Geocode/" + id, marker, function () {
                      alert("success?");
                  });
              }
          });
  
      });
  </code></pre>
  
  <p>** Another Update **</p>
  
  <p>I really need to save the geocoded address for later, even if I store the latitude/longitude values in my database and remake the marker when I'm ready to put it onto a map. Again, serializing or posting - seemingly using the point in any way other than in google maps functions gives the <code>this.lat is not a function</code> exception in my error log. </p>
  
  <p>I'm using asp.net mvc - are there any frameworks out there that would make this easier? I really need help with this. Thanks.</p>