【问题标题】:Google Places Autocomplete for French Cities法国城市的 Google 地方信息自动填充功能
【发布时间】:2016-01-30 15:44:54
【问题描述】:

我正在为法国网络应用程序构建城市自动完成功能。在法国,每个城市都有一个独特的邮政编码。例如:凡尔赛的邮政编码:78000

所以理论上,你可以通过输入城市得到邮政编码,通过输入邮政编码得到城市。

根据 Google Places 文档,您可以通过将类型设置为 '(regions)' 来获取邮政编码:https://developers.google.com/places/supported_types#table3

'(regions)''(cities)' 我都试过了,但无法返回邮政编码:

var autocomplete = new google.maps.places.Autocomplete(document.getElementById('autocomplete'), {
    types: '(regions)',
    componentRestrictions: {
        country: 'fr'
    }
});

这是一个小提琴:http://jsfiddle.net/sikko/mp4hLf7p/1/

有什么想法吗?提前致谢。

【问题讨论】:

  • 您必须在自动完成返回后使用地理编码器才能获得所需的详细地址

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


【解决方案1】:

它返回邮政编码。 address_components 中的第 4 个元素。

{ "long_name": "75003", "short_name": "75003", “类型”:[ “邮政编码” ] }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-20
    • 2015-08-05
    • 2020-08-04
    • 2013-12-09
    • 2012-01-27
    • 2016-11-30
    相关资源
    最近更新 更多