【问题标题】:Google places autocomplete suggestion without country name谷歌放置没有国家名称的自动完成建议
【发布时间】:2018-01-03 15:43:06
【问题描述】:

我正在寻找一种可以在没有国家名称的情况下获得建议的可能性。

我有以下js代码:

... var autocomplete_pickup = new google.maps.places.Autocomplete(pickup_field, {
       types: ["address"], componentRestrictions: {country: "de"}
}); ...

结果是例如

Bahnhofstrasse 4, Hamburg, Deutschland

现在我只想拥有那个例子

Bahnhofstrasse 4, Hamburg

我已将国家/地区限制为德国,因此无需显示国家/地区名称。

你有什么想法吗? 谢谢。 海因茨-彼得

【问题讨论】:

    标签: api autocomplete google-places country


    【解决方案1】:

    要解决它,只需将此查询参数 &region=de 添加到您的脚本路径中

    好像是这样的:

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=[API-KEY]&libraries=places&region=de"></script>
    

    它帮助了我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-23
      • 1970-01-01
      • 1970-01-01
      • 2017-12-23
      相关资源
      最近更新 更多