Reputation: 1
I've been looking around for possible solutions or confirmation on issue where querying on place_id returned from Google Autocomplete API the results are not consistent with the place details service.
Example with query string - 44 London Road, Sevenoaks, TN131A
Request to autocomplete API:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=44%20London%20Road,%20Sevenoaks,%20TN131A&types=address&components=country:uk&key=KEY
Result:
{
"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"
}
The results returned by autocomplete are the ones I would expect
1) One result
2) Address description contains correct full address with postcode TN13 1AS
Now, when I take the place_id and query on place details I would expect more granular details about the address. However, what I'm getting back is address which is similar to the one from autocomplete, but with different postcode which is not nowhere near the original result.
Request to place details API:
https://maps.googleapis.com/maps/api/place/details/json?placeid=EiY0NCBMb25kb24gUm9hZCwgU2V2ZW5vYWtzIFROMTMgMUFTLCBVSw&key=KEY
Result:
{
"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"
}
As you can see, the postcode returned from place details is TN13 2UG not TN13 1AS as in original suggested address.
Also, the differences between suggested address and place details address are as follows:
autocomplete: 44 London Road, Sevenoaks TN13 1AS, UK
place details: 44 London Rd, Dunton Green, Sevenoaks TN13 2UG, UK
My question here is - am I missing something when querying for granular place details? Should I be using different approach on looking up address details?
Or, possibly, its a know issue as all place details are not in sync and most possibly be the same case for other search results as well.
UPDATE:
This question got big, fat duplicate stamped on it under https://issuetracker.google.com/issues/78900692.
The referenced duplicate issue can be seen here: https://issuetracker.google.com/issues/35823492
Long story short - yes, there is an issue. Yes, they are working on it. No, there is no ETA.
Upvotes: 0
Views: 1974
Reputation: 200
You are using the wrong place ID for your input query. It is expected that the place details results on both autocomplete and place details will be different. Upon checking your input location on your first query, the correct place ID is: ChIJB5CTmvlN30cR5R2FxZO5_88
Check out the below queries:
Both of these queries return the same results because location and place ID matched.
Upvotes: 1