title: Google Maps API Reverse Lookup Address Details Accuracy
body: <p>I am using Google Maps API for reverse lookup of an address, specifically Country, City and ZIP code. The problem I have is that with geocoder when you input a specific lat lng you get a range of results based on the address detail accuracy. For example if you click on the street you get address detail accuracy of 8 and the address looks like this; <strong>"street, city, country code"</strong> or <strong>"street, city zip code, country code"</strong>. And if you click on another location you can get address detail accuracy of 5 which returns; city zip code, country code.</p>
  
  <p>All I am looking for is the the city, zip code and country. Is there any way to force Google maps to return address detail accuracy of 5 all the time or to return the elements broken up into individual parts i.e. city, zip code and country.</p>
  
  <p>This is the code I am using to get the information:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"&gt; 
    &lt;head&gt; 
      &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"/&gt; 
      &lt;title&gt;Google Maps JavaScript API Example:  Reverse Geocoder&lt;/title&gt; 
      &lt;script src="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=ABQIAAAAMkjr3Dq_jK6GSFYDFzaHTBRoJ0TBOI_XK4bTNi9dL2l04KlxphRNL_k0peOib9IHF6T2KwlVmOb6uQ" type="text/javascript"&gt;&lt;/script&gt; 
      &lt;script type="text/javascript"&gt;
  
          var map;
          var geocoder;
          var address;
  
          function initialize() {
  
              var zoom = 10;
  
              map = new GMap2(document.getElementById("map_canvas"));
              map.setCenter(new GLatLng(40.730885, -73.997383), zoom);
              map.setUIToDefault();
              GEvent.addListener(map, "click", getAddress);
              geocoder = new GClientGeocoder();
          }
  
          function getAddress(overlay, latlng) {
              if (latlng != null) {
                  address = latlng;
                  geocoder.getLocations(latlng, showAddress);
              }
          }
  
          function showAddress(response) {
              map.clearOverlays();
              if (!response || response.Status.code != 200) {
                  alert("Status Code:" + response.Status.code);
              } else {
                  place = response.Placemark[0];
                  point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
                  marker = new GMarker(point);
                  map.addOverlay(marker);
  
                  var message = '&lt;b&gt;orig latlng:&lt;/b&gt;' + response.name + '&lt;br/&gt;' +
                                  '&lt;b&gt;latlng:&lt;/b&gt;' + place.Point.coordinates[1] + "," + place.Point.coordinates[0] + '&lt;br&gt;' +
                                  '&lt;b&gt;Status Code:&lt;/b&gt;' + response.Status.code + '&lt;br&gt;' +
                                  '&lt;b&gt;Status Request:&lt;/b&gt;' + response.Status.request + '&lt;br&gt;' +
                                  '&lt;b&gt;Address:&lt;/b&gt;' + place.address + '&lt;br&gt;' +
                                  '&lt;b&gt;Accuracy:&lt;/b&gt;' + place.AddressDetails.Accuracy + '&lt;br&gt;' +
                                  '&lt;b&gt;Country code:&lt;/b&gt; ' + place.AddressDetails.Country.CountryNameCode;
  
                  marker.openInfoWindowHtml(message);
              }
          }
  
  
      &lt;/script&gt; 
    &lt;/head&gt; 
  
    &lt;body onload="initialize()"&gt; 
      &lt;div id="map_canvas" style="width: 800px; height: 600px"&gt;&lt;/div&gt; 
    &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated. My last resort would be to parse the address string but it feels like an overkill. There must be a cleaner way.</p>
  
  <p>I am currently looking at the getLocations() method maybe parsing the JSON result could yield the fields I am looking for.</p>
  
  <p>Thanx.</p>