最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google Places Autocomplete API filter by multiple countries - Stack Overflow

programmeradmin1浏览0评论

Looking for a way to filter the autoplete results filtered by 2 countries, Canada and US.

Currently I can only filter by one or the other with options like this...

var options = {
  types: ['(cities)'],
  ponentRestrictions: {country: 'us'}
}
var autoplete = new google.maps.places.Autoplete(input,options);

... but I have not seen any documentation that explains how to restrict autoplete results to 2 countries.

Any help is appreciated.

Looking for a way to filter the autoplete results filtered by 2 countries, Canada and US.

Currently I can only filter by one or the other with options like this...

var options = {
  types: ['(cities)'],
  ponentRestrictions: {country: 'us'}
}
var autoplete = new google.maps.places.Autoplete(input,options);

... but I have not seen any documentation that explains how to restrict autoplete results to 2 countries.

Any help is appreciated.

Share Improve this question asked Jun 15, 2012 at 8:49 mgauthiermgauthier 3312 silver badges6 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

The Google Places API does not currently support this feature. If you believe this would be a useful feature you can submit a 'Places API - Feature Request' here.

UPDATE

This feature was introduced in version 3.27 of Maps JavaScript API in January 2017:

You can now restrict Autoplete predictions to only surface from multiple countries. You can do this by specifying up to 5 countries in the ponentRestrictions field of the AutopleteOptions.

https://developers.google./maps/documentation/javascript/releases https://developers.google./maps/documentation/javascript/reference#ComponentRestrictions

发布评论

评论列表(0)

  1. 暂无评论