0

I am running Google Places Autocomplete on my search input on a website. Works like clockwork.

What I want is to limit the suggestions from Google (cities in this case) to a predefined set of cities (e.g. Amsterdam, Paris, berlin, and so forth).

Is there a way I can do this? I have scanned Google's API pages as well as stackoverflow but haven't been able to find an answer.

(I guess in essence what I want is the to change the immense database Google uses to one with just a dozen or so cities.)

Thanks!

  • I'm not sure if this can be resolved by using the `regions` filter with a `postal_code` type, might at least be worth a mention https://developers.google.com/places/supported_types – Lars Beck Apr 20 '17 at 17:10

1 Answers1

0

This question was answered in the past - Refer to this link: How to limit google autocomplete results to City and Country only

function initialize() {

 var options = {
  types: ['(cities)'],
  componentRestrictions: {country: "us"}
 };

 var input = document.getElementById('searchTextField');
 var autocomplete = new google.maps.places.Autocomplete(input, options);
}
Community
  • 1
  • 1
Damien
  • 1,582
  • 1
  • 13
  • 24