【问题标题】:Google maps componentRestrictions not working谷歌地图组件限制不起作用
【发布时间】:2015-04-29 09:23:21
【问题描述】:

我正在使用谷歌地图 javascript api 将带有 componentRestrictions 设置的 SearchBox 放置到国家 cz。

但要在所有国家/地区自动完成。

const AUTOCOMPLETE_OPTIONS = {
 types: ['address'],
 componentRestrictions: {
    country: 'cz'
 }
};
new google.maps.places.SearchBox(inputPlaceElement, AUTOCOMPLETE_OPTIONS);

如果将创建的对象转储到控制台 componentRestrictions 设置为我想要的但在请求 url 中没有关于此限制的任何内容,则应该是 GetPredictions 而不是 GetQueryPredictions:

https://maps.googleapis.com/maps/api/js/AutocompletionService.GetQueryPredictions?1sb&4scs&15e3

我不确定这里哪里有问题,如果我设置其他国家代码也不起作用。

【问题讨论】:

  • 把它变成一个自动完成。根据documentation,您只能使用LatLngBounds 对象来偏向预测。

标签: javascript google-maps google-maps-api-3


【解决方案1】:

SearchBox 不支持componentRestrictions,此选项适用于Autocomplete

【讨论】:

  • 是一种限制搜索框的方法吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-09-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-01-10
相关资源
最近更新 更多