title: Issue with Geocoding in Google Maps API
body: <p>Im trying out the Google Maps API Geocoding feature.The map loads fine, but im facing an issue with geocoding.I have a text box on the page where i enter the location, and on clicking the submit button, i would like to pinpoint the entered location on the map.</p>
  
  <p>The setCenter method correctly marks the location on the map, first time i call it with predefined coordinates. But when called from within the callback function i defined for getLatLng,the location on the map does not change to reflect the location entered by the user.</p>
  
  <p>Any help regarding how to fix this would be really appreciated. Below is my code.</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Google Maps&lt;/title&gt;
          &lt;script type="text/javascript" src="http://www.google.com/jsapi?key=my_api_key"&gt; &lt;/script&gt;
          &lt;script type="text/javascript" charset="utf-8"&gt;
              google.load("maps", "2.x");
              google.load("jquery", "1.3.1");
          &lt;/script&gt;
  
          &lt;script&gt;
  
  
            $(document).ready(function(){
              var map = new GMap2(document.getElementById('map'));
              var burnsvilleMN = new GLatLng(44.797916,-93.278046);
              map.setCenter(burnsvilleMN, 8);
  
                $("#add-point").submit(function(){
                  geoEncode();
                  return false;
               });
            });
  
            function geoEncode(){
  
              var geocoder = new GClientGeocoder();
              var reasons = [];
              reasons[G_GEO_SUCCESS] = "Success";
              reasons[G_GEO_MISSING_ADDRESS] = "Missing Address";
              reasons[G_GEO_UNKNOWN_ADDRESS] = "Unknown Address.";
              reasons[G_GEO_UNAVAILABLE_ADDRESS] = "Unavailable Address";
              reasons[G_GEO_BAD_KEY] = "Bad API Key";
              reasons[G_GEO_TOO_MANY_QUERIES] = "Too Many Queries";
              reasons[G_GEO_SERVER_ERROR] = "Server error";
  
              var address = $("#add-point input[name=address]").val();
              if (geocoder) {
  
                  geocoder.getLatLng(address, function(point){
                      if (!point) {
                          alert(address + " not found");
                      }
                      else {
  
                          map.setCenter(point, 13);
                          var marker = new GMarker(point);
                          map.addOverlay(marker);
                          marker.openInfoWindowHtml(address);
                      }
                  });
              }
              else {
                  alert("Some Error :(");
              }
  
            }
          &lt;/script&gt; 
        &lt;style type="text/css"&gt;
  
            #map { width:500px; height:500px;float:right;}
            #add-point { float:left; }
            div.input { padding:3px 0; }
            label { display:block; font-size:80%; }
            input, select { width:150px; }
            button { float:right; }
            div.error { color:red; font-weight:bold; }
  
  
        &lt;/style&gt;
  
      &lt;/head&gt;
  
  
      &lt;body&gt;
  
          &lt;form id="add-point" action="" method="POST"&gt;
               &lt;input type="hidden" name="action" value="savepoint" id="action"&gt;
  
            &lt;fieldset&gt;
                &lt;legend&gt;Add a Point to the Map&lt;/legend&gt;
                &lt;div class="error" style="display:none;"&gt;&lt;/div&gt;
  
                &lt;div class="input"&gt;
  
                    &lt;label for="name"&gt;Location Name&lt;/label&gt;
  
                    &lt;input type="text" name="name" id="name" value=""&gt;
  
                &lt;/div&gt;
  
                &lt;div class="input"&gt;
  
                    &lt;label for="address"&gt;Address&lt;/label&gt;
  
                    &lt;input type="text" name="address" id="address" value=""&gt;
  
                &lt;/div&gt;
  
                &lt;button type="submit"&gt;Add Point&lt;/button&gt;
  
            &lt;/fieldset&gt;
  
        &lt;/form&gt;
  
        &lt;div id="map"&gt;&lt;/div&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thank You.</p>