【问题标题】:Google Places Autocomplete returns place_id linked to erroneous placeGoogle 地方信息自动填充功能返回与错误地点相关联的 place_id
【发布时间】:2018-06-30 20:58:55
【问题描述】:

https://maps.googleapis.com/maps/api/place/autocomplete/json?language=fr&input=5+avenue+de+l%27union+p&radius=50000&location=48.2%2C2.3

此调用返回:

{
    'description': u "5 Avenue de l'Union, Paray-Vieille-Poste, France",
    'place_id': 'EjA1IEF2ZW51ZSBkZSBsJ1VuaW9uLCBQYXJheS1WaWVpbGxlLVBvc3RlLCBGcmFuY2U',
    'id': '0762652b32b4b27a6be6c89d706c1e1279073e9f',
...
}

然后,在请求地点详细信息时

https://maps.googleapis.com/maps/api/place/details/json?placeid=EjA1IEF2ZW51ZSBkZSBsJ1VuaW9uLCBQYXJheS1WaWVpbGxlLVBvc3RlLCBGcmFuY2U

它返回一个 不是预期的地方。显然与另一个城市的相同街道名称混淆(“Juvisy”与“Paray-Vieille-Poste”):

 {
     'status': 'OK',
     'html_attributions': [],
     'result': {
         'utc_offset': 60,
         'name': u "5 Avenue de l'Union",
         'reference': 'CpQBkAAAAKfctAfslcVNWK_kGk6gzecawbnBT8JD5Tchnyheh0SyULvlV6XlyZpjkExmykkL3_2lvm5ZoHRAxqO7GPra2vt11osAzE2RJdcT7Fc7c069IpHgvsdJpmNvWb3FjMIrn092DmQj-GKlfAmA9pvvAw6zyKJfd1XQFK88Kl09CULdpxM9vMb-AIfHhGwUe6KP7RIQ2r3XA3Xjax5iCDWbuiZqNBoUqy-PYeUYY9xA_I65wZjdQLQXsVE',
         'geometry': {
             'location': {
                 'lat': 48.69058269999999,
                 'lng': 2.3692054
             },
             'viewport': {
                 'northeast': {
                     'lat': 48.6919374802915,
                     'lng': 2.370557630291501
                 },
                 'southwest': {
                     'lat': 48.6892395197085,
                     'lng': 2.367859669708498
                 }
             }
         },
         'adr_address': '<span class="street-address">5 Avenue de l&#39;Union</span>, <span class="postal-code">91260</span> <span class="locality">Juvisy-sur-Orge</span>, <span class="country-name">France</span>',
         'place_id': 'EjI1IEF2ZW51ZSBkZSBsJ1VuaW9uLCA5MTI2MCBKdXZpc3ktc3VyLU9yZ2UsIEZyYW5jZQ',
         'vicinity': 'Juvisy-sur-Orge',
         'url': 'https://maps.google.com/?q=5+Avenue+de+l%27Union,+91260+Juvisy-sur-Orge,+France&ftid=0x47e5df5943bfe633:0x24dc923a0494f142',
         'scope': 'GOOGLE',
         'address_components': [{
             'long_name': '5',
             'types': ['street_number'],
             'short_name': '5'
         }, {
             'long_name': u "Avenue de l'Union",
             'types': ['route'],
             'short_name': u "Avenue de l'Union"
         }, {
             'long_name': 'Juvisy-sur-Orge',
             'types': ['locality', 'political'],
             'short_name': 'Juvisy-sur-Orge'
         }, {
             'long_name': 'Essonne',
             'types': ['administrative_area_level_2', 'political'],
             'short_name': 'Essonne'
         }, {
             'long_name': '\xcele-de-France',
             'types': ['administrative_area_level_1', 'political'],
             'short_name': '\xcele-de-France'
         }, {
             'long_name': 'France',
             'types': ['country', 'political'],
             'short_name': 'FR'
         }, {
             'long_name': '91260',
             'types': ['postal_code'],
             'short_name': '91260'
         }],
         'formatted_address': u "5 Avenue de l'Union, 91260 Juvisy-sur-Orge, France",
         'id': 'f63ea1e7a3679ec740d0041fa0166161493ace38',
         'types': ['street_address'],
         'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png'
     }
 }

【问题讨论】:

标签: google-places-api


【解决方案1】:

这里解释:https://developers.google.com/places/place-id#id-overview

你可以有 2 种类型的 places_id,一种较短的盯着 Ch 像:

ChIJrTLr-GyuEmsRBfy61i59si0

和你正在使用的以 E 开头的更长的类似:

EisxMyBNYXJrZXQgU3RyZWV0LCBXaWxtaW5ndG9uLCBOQyAyODQwMSwgVVNB

总结一下,什么时候插值较长,这意味着谷歌试图猜测(计算)地址在哪里。我的观点是,较短的更准确,而较长的则不太可行。

我是否应该建议将此问题报告为问题跟踪器中正确 API 中的错误。

https://issuetracker.google.com

编码愉快:)

【讨论】:

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