Given the following API call to autocomplete:
https://maps.googleapis.com/maps/api/place/autocomplete/json?types=address&input=23 norton st
I get the following response:
{ "predictions": [ { "description": "23 Norton Street, Leichhardt, New South Wales, Australia", "id": "9711c656faa60f77a05680b603523a4bc75c45be", "place_id": "EjgyMyBOb3J0b24gU3RyZWV0LCBMZWljaGhhcmR0LCBOZXcgU291dGggV2FsZXMsIEF1c3RyYWxpYQ", "types": [ "route", "geocode" ] }, ... ], "status": "OK" }
Notice the types are of route and geocode.
If I query the detail API:
I get the following:
{ "html_attributions": [], "result": { "id": "e698fdcd9dceed8fe42a926a19cb2b17d4f5f088", "name": "23 Norton St", "place_id": "ChIJpdXOTxewEmsRMmpMxLBgFpI", "reference": "CmRbAAAAKmYoyR1BrFqFQJi6CAD8cjhD4SDnZXMIC0mOLOpX_jPgIgFv0TJ3rv8p5L9xKrplHzUFxBNc8sd7PdkXdnCsTo_7-3X7mocd8yHnXCIKYAxj0MO4icLoFJjD3DEszqK3EhD8XIu6zNH-h3hqotfKjmd-GhRwyNIfJCo4bmOOLYgubm7j8ln_tw", "scope": "GOOGLE", "types": [ "street_address" ], "url": "https://maps.google.com/?q=23+Norton+St,+Leichhardt+NSW+2040,+Australia&ftid=0x6b12b0174fced5a5:0x921660b0c44c6a32", "utc_offset": 600, "vicinity": "Leichhardt" }, "status": "OK" }
The types are completely different as well as the place id?!
2 Answers
Answers 1
If you do the search for "23 Norton Street" rather than "23 Norton St" you actually get the results you'd expect (matching place_id, type etc). I think what is happening is that when you search for 23 Norton St it doesn't actually have a match (as St rather than Street) and so it performs a geocode lookup, and that's the result you see.
Is there any reason the result is causing problems for you? Or is it just an oddity/curiosity?
Answers 2
Not sure what your actual issue is, but it is possible for Google Places to actually have multiple IDs for one location. Reference: https://developers.google.com/places/place-id
Also it seems you may have your AutoComplete setup to only provide you back types regarding geocode
and route
as that is also an option for results. It's unknown without your actual code.
I'm sure you have been to the documentation here: https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete
but maybe you missed something in the example there. Hope that answers your 'question'!
0 comments:
Post a Comment