Viewing 6 replies - 1 through 6 (of 6 total)
  • Also wondering this – any update?

    Posting a follow up to this question as I resolved it myself.

    open js/map_data.js

    Add the following line:

    autocomplete.setComponentRestrictions({‘country’: [‘AU’]});

    Must be the countries ISO code, can add multiple also .. e.g. [‘AU’,’US’]

    Add it after the autocomplete variable has been set.

    e.g.

    var autocomplete = new google.maps.places.Autocomplete(
                document.getElementById(inputFull),
                {
                    types: ["geocode"],
                }
            );
    
            autocomplete.setComponentRestrictions({'country': ['AU']});

    I also need this feature but can’t get the above line of code to work…

    When I add:

    autocomplete.setComponentRestrictions({‘country’: [‘NZ’]});

    as advised above for New Zealand, it fails to look up anything at all?

    What am I doing wrong? Any help would be much appreciated!

    That worked perfectly, thank you!

    @flyingkiwi15 do you still need help?

    @arrowtech Yes, I’d love some help if you were able to offer it. I had to give up on getting it to work for now…

    @webido Thank you so much, that worked perfectly!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Limit autocomplete results to a specific country’ is closed to new replies.