title: Getting the street address from a google maps geocode call
body: <p>I am geocoding an address using google maps API, and I need to get the street address, city, state, and zip in distinct fields. Based on the documentation of the <a href="https://developers.google.com/maps/documentation/geocoding/#Types" rel="noreferrer">address component types</a> that are returned in the result, this is my code:</p>
  
  <pre><code>var address = "";
  var city = "";
  var state = "";
  var zip = "";
  
  geocoder.geocode( { 'address': inputAddress}, function(results, status){
      if (status==google.maps.GeocoderStatus.OK){
          // loop through to get address, city, state, zip
          $.each(results[0].address_components, function(){
              switch(this.types[0]){
                  case "postal_code":
                      zip = this.short_name;
                      break;
                  case "street_address":
                      address = this.short_name;
                      break;
                  case "administrative_area_level_1":
                      state = this.short_name;
                      break;
                  case "locality":
                      city = this.short_name;
                      break;                  
              }
          });
      } else{ alert("Invalid Address"); }
  });
  </code></pre>
  
  <p>However, it seems that when I enter addresses, "street_address" is not being returned; instead, it is returned as separate fields, most often "street_number" and "route", occasionally additional fields (such as "subpremise" for apt number). See <a href="https://developers.google.com/maps/documentation/geocoding/#JSON" rel="noreferrer">this example of a geocoding result</a> in the docs.</p>
  
  <p>How can I get an address variable that holds any fields related to the street address? For the example in the docs, I would want "1600 Ampitheatre Parkway".</p>