3

Is there a way to make Google Places Autocomplete restricted to one country like France?

I have this: components=country:fr

https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true&libraries=places&language=fr&components=country:fr&key=API_KEY

But this didn't restrict the autocomplete.

medk
  • 9,233
  • 18
  • 57
  • 79

1 Answers1

2

This code works for me.

var input = document.getElementById('city_field');
    var options = {
      types: ['(cities)'],
      componentRestrictions: {country: countryCode},
        language: "en"
    };

    autocomplete = new google.maps.places.Autocomplete(input, options);

Double check the parameter name components=country:fr syntax

Sameer Naik
  • 1,326
  • 1
  • 13
  • 28