Google商家信息自动填充仅限于定义的城市

时间:2017-04-20 16:51:47

标签: javascript jquery google-places-api

我在网站上的搜索输入上运行Google商家信息自动填充功能。就像发条一样。

我想要的是将Google(本案例中的城市)的建议限制在一组预定义的城市(例如阿姆斯特丹,巴黎,柏林等)。

有没有办法可以做到这一点?我扫描了Google的API页面以及stackoverflow,但还没有找到答案。

(我想我想要的是将谷歌使用的巨大数据库改为只有十几个城市的数据库。)

谢谢!

1 个答案:

答案 0 :(得分:0)

过去回答过这个问题 -  请参阅此链接: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);
}