title: Google Geocoding and Autocomplete do not return the same number of results
body: <p>For the same address entered by the user in the address input, the google <strong>Autocomplete API</strong> on the front-end (with javacript) returns <strong>a single result</strong> and thus <strong>a single choice for the user</strong>.
  Whereas the <strong>Geocoder API</strong> on the back-end (PHP) returns <strong>two different results</strong>.</p>
  
  <p>I have a back-end validation that gets the address entered by the user thanks to Autocomplete and checks this address with geocoder. If I have no results with the geocoder or more than one result (which is my case, since I get 2 results with the geocoder), I throw an exception.</p>
  
  <p>This is an issue for me because my validation with the geocoder should be able to rely on the Autocomplete.</p>
  
  <p>Please find below my extra explanation</p>
  
  <p><strong>Explanation:</strong></p>
  
  <p>I have a form on my website, where the user enters his address in an address input. This input uses the google Autocomplete API with javascript as follow.</p>
  
  <pre><code>var addressAutocompleteGoogleMaps = new google.maps.places.Autocomplete($myInputJqueryElement[0], {
      componentRestrictions: {country: 'fr'},
      types: ['geocode']
  });
  
  addressAutocompleteGoogleMaps.addListener('place_changed', function() {
      var addressAutocompleteSelectedAddress = $myInputJqueryElement.val();
      var autocompletionFormattedAddress = addressAutocompleteGoogleMaps.getPlace().formatted_address;
      $myInputJqueryElement.val(autocompletionFormattedAddress);
  
      // After having changed my form value to the formatted_address, I submit the form.
  });
  </code></pre>
  
  <p>Now if the user enters the following address</p>
  
  <pre><code>21bis Rue Claude Bernard, 75005 Paris, France
  </code></pre>
  
  <p>(as you can see there is a space missing between the <code>21</code> and the <code>bis</code> in the address), well on the front end-side, <strong>google Autocomplete seems to recognize this address and gives the user a single unique choice</strong>. As you can see below:</p>
  
  <p><a href="https://i.stack.imgur.com/lzi1C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lzi1C.png" alt="enter image description here"></a></p>
  
  <p>if I perform a <code>console.log(addressAutocompleteGoogleMaps.getPlace());</code>, I can see a single result in my console, with the following attributes:</p>
  
  <pre><code>place_id: "ChIJzX6RiOtx5kcRCaog3ti3QTs"
  formatted_address: "21bis Rue Claude Bernard, 75005 Paris, France"
  geometry: {location: _.P, viewport: _.Q}
  </code></pre>
  
  <p>But in my back-end, I use the geocoder service of Google and do not tolerate more than one result from the API.</p>
  
  <p>If I use the same address as the <code>formatted_address</code> of the Autocomplete result on the front-end, which is <code>21bis Rue Claude Bernard, 75005 Paris, France</code>, and I submit it to the geocoder API on my back-end with to this URL</p>
  
  <pre><code>https://maps.googleapis.com/maps/api/geocode/json?key=myKey&amp;language=fr&amp;region=fr&amp;address=21bis+Rue+Claude+Bernard%2C+75005+Paris%2C+France 
  </code></pre>
  
  <p>(as you can see in the URL parameters, there is no space between <code>21</code> and <code>bis</code> because the submitted address by my user, based on the choice of Google Autocomplete does not contain a space either)</p>
  
  <p>I get the following results from the geocoder:</p>
  
  <p><a href="https://i.stack.imgur.com/3yitE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3yitE.png" alt="enter image description here"></a></p>
  
  <p>As you can see I get two results with the geocoder from the address <code>21bis Rue Claude Bernard, 75005 Paris, France</code>.</p>
  
  <p>But I only get one result with the Autocomplete.</p>
  
  <p>Event the place_ids are not the same. With the autocomplete API, the place_id is <code>ChIJzX6RiOtx5kcRCaog3ti3QT</code>. But with the geocode API, I get two other place_ids, which are <code>ChIJVeIPVu9x5kcRPHRX59oID5M</code> and <code>ChIJG9djYOxx5kcR1JtnnCReAxU</code>.</p>
  
  <p><strong>WHAT I WOULD LIKE</strong></p>
  
  <p><strong>Why does the Google Geocoder not return the same results as the Google Autocomplete? How can I solve my problem?</strong></p>
  
  <p><strong>I want:</strong></p>
  
  <p><strong>- either my Autocomplete to return the same 2 results as my geocoder</strong></p>
  
  <p><strong>- either my geocoder to return a single result, the same as the Autocomplete</strong></p>
  
  <p>(ps: And by the way, I tried typing the same address on the online geocoder of Google on <a href="https://developers.google.com/maps/documentation/geocoding/intro" rel="nofollow noreferrer">https://developers.google.com/maps/documentation/geocoding/intro</a> and I also get a single address as you can see below. So how come my back-end usage of the geocoding API still return 2 results??)</p>
  
  <p><a href="https://i.stack.imgur.com/ge4gk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ge4gk.png" alt="enter image description here"></a></p>