1
votes

Given the following API call to autocomplete:

https://maps.googleapis.com/maps/api/place/autocomplete/json?types=address&input=23%20norton%20st

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:

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

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 and the place id are different from the first response. I would expect them to be the same, why are they different?

2
Just because you put a bounty on this question it doesn't become a good question. I am flagging your question as unclear. Can you please elaborate on the actual problem you are having? You are calling an API and the types are different as you showed with an example, so that would automatically answer your own question The types are completely different as well as the place id?! Yes they are. - GabrielOshiro
If you read the commnents: _ I need to filter autocomplete by street addresses only, but it it is discounting some addresses like this even though it is an actual street address_ - morrislaptop
It is your question, you can do whatever you want with it. I am just saying that if you really need help from the community you might want to clarify it a little bit. I just read it again and I still don't see what your problem is... - GabrielOshiro

2 Answers

2
votes

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?

0
votes

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'!