GoogleMap Custom AutoComplete 1 Country

Viewed 18

Good afternoon! I found a good code on the web, GoogleMap Custom AutoComplete, you can see it here:

https://embed.plnkr.co/IWj3w4/

In the js script, there are several lines like this:

function initialize() {

  autocomplete = new google.maps.places.Autocomplete(
    /** @type {HTMLInputElement} */
    (document.getElementById('autocomplete')), {
      types: ['geocode']
    });
  // When the user selects an address from the dropdown,
  // populate the address fields in the form.
  google.maps.event.addListener(autocomplete, 'place_changed', function() {
    fillInAddress();
  });
  
  autocomplete_postalcode = new google.maps.places.Autocomplete(
    (document.getElementById("AutocompletePostalCode")), {
     types: ['(regions)'],
     componentRestrictions: {country: 'fr'}
    });

As you can see from the code, it should only work for the "FR" country, but it works worldwide. How to make 1 specific country in this code? For example USA or Canada?

Thanks a lot! I hope for your help

0 Answers
Related