title: Can I restrict google geocoder results by cities and towns?
body: <p>There are <a href="https://developers.google.com/maps/documentation/javascript/reference/geocoder" rel="noreferrer">component restrictions</a> for the google geocoding api.</p>
  
  <blockquote>
    <p>admininstrativeArea, country, locality, postalCode, route</p>
  </blockquote>
  
  <p>can I use any of these to filter by city and town?
  So that I don't get back a country or state?</p>
  
  <p>Something like </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>this.geocoder = new google.maps.Geocoder();
  this.geocoder.geocode({
        address: this.registerForm.get('city').value,
        componentRestrictions: {
          country: 'US',
          locality // not sure here
        }
      },
      (results, status) =&gt; {
        if (status === google.maps.GeocoderStatus.OK) {}
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I can do it with google maps autocomplate!</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>this.autocomplete = new google.maps.places.Autocomplete(this.element, {
    types: ['(cities)']
  });</code></pre>
  </div>
  </div>
  </p>