Google自动填充限制超过1个国家/地区

时间:2015-11-02 15:55:54

标签: api autocomplete

是否可以过滤超过1个国家/地区?

我试过了:

componentRestrictions: {country: "us","uk"}

但是没有用。

完整代码:

<script src="http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places" type="text/javascript"></script>
<script type="text/javascript">
   function initialize() {
      var options = { 
  types: ['(cities)'],
  componentRestrictions: {country: "us","uk"}
 };

 var input = document.getElementById('searchTextField');
 var autocomplete = new google.maps.places.Autocomplete(input, options);

}

   google.maps.event.addDomListener(window, 'load', initialize);
</script>

1 个答案:

答案 0 :(得分:0)

componentRestrictions: {country: "us", country: "ca"}

它的作品就像魅力:)