我一直在寻找可能的解决方案或确认问题,查询从 Google自动填充API 返回的 place_id ,结果与地点详细信息不一致服务。
查询字符串示例 - 44 London Road,Sevenoaks,TN131A
请求自动填充API:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=44%20London%20Road,%20Sevenoaks,%20TN131A&types=address&components=country:uk&key=KEY
结果:
{
"predictions": [
{
"description": "44 London Road, Sevenoaks TN13 1AS, UK",
"id": "a68cc04956c7d845e7ecf4310ab7e37c8b1726bc",
"matched_substrings": [
{
"length": 14,
"offset": 0
},
{
"length": 8,
"offset": 26
}
],
"place_id": "EiY0NCBMb25kb24gUm9hZCwgU2V2ZW5vYWtzIFROMTMgMUFTLCBVSw",
"reference": "CjQqAAAAO-BUieTtItdrzdJeUH3XgoqPQDQkb8adId4-OgGtQ69p1xImSYbX9cOIutz64vodEhApHwR2GWECK1--3E9m3Jz-GhQQBNtahApp19gUfuIWJLESCavJfw",
"structured_formatting": {
"main_text": "44 London Road",
"main_text_matched_substrings": [
{
"length": 14,
"offset": 0
}
],
"secondary_text": "Sevenoaks TN13 1AS, UK",
"secondary_text_matched_substrings": [
{
"length": 8,
"offset": 10
}
]
},
"terms": [
{
"offset": 0,
"value": "44 London Road"
},
{
"offset": 16,
"value": "Sevenoaks"
},
{
"offset": 26,
"value": "TN13 1AS"
},
{
"offset": 36,
"value": "UK"
}
],
"types": [
"route",
"geocode"
]
}
],
"status": "OK"
}
自动完成返回的结果是我期望的结果
1)一个结果
2)地址描述包含正确的完整地址,邮政编码为 TN13 1AS
现在,当我使用 place_id 并查询地点详细信息时,我希望有更详细的地址详细信息。但是,我收到的地址与自动完成的地址相似,但邮政编码与原始搜索结果不同。
要求提供详细信息API:
https://maps.googleapis.com/maps/api/place/details/json?placeid=EiY0NCBMb25kb24gUm9hZCwgU2V2ZW5vYWtzIFROMTMgMUFTLCBVSw&key=KEY
结果:
{
"html_attributions": [],
"result": {
"address_components": [
{
"long_name": "44",
"short_name": "44",
"types": [
"street_number"
]
},
{
"long_name": "London Road",
"short_name": "London Rd",
"types": [
"route"
]
},
{
"long_name": "Dunton Green",
"short_name": "Dunton Green",
"types": [
"locality",
"political"
]
},
{
"long_name": "Sevenoaks",
"short_name": "Sevenoaks",
"types": [
"postal_town"
]
},
{
"long_name": "Kent",
"short_name": "Kent",
"types": [
"administrative_area_level_2",
"political"
]
},
{
"long_name": "England",
"short_name": "England",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "United Kingdom",
"short_name": "GB",
"types": [
"country",
"political"
]
},
{
"long_name": "TN13 2UG",
"short_name": "TN13 2UG",
"types": [
"postal_code"
]
}
],
"adr_address": "<span class=\"street-address\">44 London Rd</span>, <span class=\"extended-address\">Dunton Green</span>, <span class=\"locality\">Sevenoaks</span> <span class=\"postal-code\">TN13 2UG</span>, <span class=\"country-name\">UK</span>",
"formatted_address": "44 London Rd, Dunton Green, Sevenoaks TN13 2UG, UK",
"geometry": {
"location": {
"lat": 51.2914523,
"lng": 0.1679203
},
"viewport": {
"northeast": {
"lat": 51.29279178029149,
"lng": 0.169216380291502
},
"southwest": {
"lat": 51.2900938197085,
"lng": 0.166518419708498
}
}
},
"icon": "https://maps.gstatic.com/mapfiles/place_api/icons/geocode-71.png",
"id": "9e62665526d3d76deb1d04b508d3afb273a6415b",
"name": "44 London Rd",
"place_id": "ChIJ77ZF32hS30cRvP2Kbxo9Eqc",
"reference": "CmRbAAAAC1pl4PwpN5mzt1MNHaUsxP9tnaaAEwBtJNi1MasmPV12-itLnnDGk8QMeoKHaeJw1mIfYvO6AWXaIZ94OEGsLAzwuOfNG_8Klza0ScrVe1U9DbOv1RyAyGh2bAQuG03zEhBEfrvBLZjXbIyMJHraFobWGhR1wJVnsIfPIwVhqpj2w2x-NIdCSg",
"scope": "GOOGLE",
"types": [
"street_address"
],
"url": "https://maps.google.com/?q=44+London+Rd,+Dunton+Green,+Sevenoaks+TN13+2UG,+UK&ftid=0x47df5268df45b6ef:0xa7123d1a6f8afdbc",
"utc_offset": 60,
"vicinity": "Dunton Green"
},
"status": "OK"
}
如您所见,从地方详细信息返回的邮政编码是 TN13 2UG 而不是 TN13 1AS ,与原始建议地址一样。
此外,建议的地址和地点详细信息地址之间的差异如下:
autocomplete :44 London Road,Sevenoaks TN13 1AS,UK
地方详情:44 London Rd,Dunton Green,Sevenoaks TN13 2UG,UK
我的问题是 - 在查询详细的地方详细信息时,我是否遗漏了一些内容?我是否应该使用不同的方法查找地址详细信息? 或者,它可能是一个已知的问题,因为所有地方的细节都不同步,而且对于其他搜索结果,大多数可能也是相同的情况。
更新:
这个问题在https://issuetracker.google.com/issues/78900692下标记了大而重的重复 引用的重复问题可以在这里看到:https://issuetracker.google.com/issues/35823492
长话短说 - 是的,有一个问题。是的,他们正在努力。不,没有ETA。
答案 0 :(得分:2)
您输入的查询使用了错误的地点ID。预计自动填充和地点详细信息的地点详细信息结果将有所不同。在第一次查询时检查输入位置后,正确的地点ID为:ChIJB5CTmvlN30cR5R2FxZO5_88
查看以下查询:
这两个查询都返回相同的结果,因为位置和地点ID匹配。