-1

To add country restrictions for google address suggestions, we can just add

autocomplete.setComponentRestrictions({"country":["US"]}); //Display US address only

autocomplete.setComponentRestrictions({"country":["US","CA"]}); //Display US, CA only

It's working fine as expected. But If I add more countries like below then I don't see addresses for few countries US, UK, FR etc:

autocomplete.setComponentRestrictions({"country":["AU","AT","BE","CA","CN","CY","EE","FI","FR","DE","GR","HK","IE","IT","JP","LV","LT","LU","MT","MC","NL","PT","SK","SI","ES","GB","US"]});

Debugging Result:

I found after CN countries not getting restricted. So I thought may be Issue with incorrect country code. But all codes are correct.

I thought may be issue with country code CY (Cyprus). But If I use. It's working.

autocomplete.setComponentRestrictions({"country":["CY"]}); //Display CY address only

Not getting what is the issue. Anyone faced Issue like this?

Akhil Gupta
  • 187
  • 3
  • 13

1 Answers1

2

You can only provide a maximum of five country codes. See the documentation:

Restricts predictions to the specified country (ISO 3166-1 Alpha-2 country code, case insensitive). For example, 'us', 'br', or 'au'. You can provide a single one, or an array of up to five country code strings.

geocodezip
  • 158,664
  • 13
  • 220
  • 245
  • If I don't give any restrictions I see all countries addresses. If need to get addresses for specific countries it's limited to 5. Not sure why they did that. Anyway Is there any option I can see addresses for more then 5 selected countries? – Akhil Gupta Oct 11 '18 at 08:42