Reputation: 51
I have a custom address input form, and perfofrm requests for Google Place API from my back-end to autocomplete user's input, but i can't get house numbers by the street. I performed requests like that:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=1 Lenin Avenue, Tomsk, Tomsk Oblast, Russia&strictbounds=true&location=56.488430, 84.948047&radius=12285.769883&types=address
I expected some results like:
"Lenin Avenue, 1, Tomsk, Tomsk Oblast, Russia"
"Lenin Avenue, 10, Tomsk, Tomsk Oblast, Russia"
"Lenin Avenue, 11, Tomsk, Tomsk Oblast, Russia"
"Lenin Avenue, 12, Tomsk, Tomsk Oblast, Russia"
etc.
But got only first result. I tried to use "components" paremeter, but API accepted only "country:XX" filter, also tried using masks like "1* Lenin Avenue, Tomsk, Tomsk Oblast, Russia".
Upvotes: 0
Views: 2080
Reputation: 1542
You'll need to use Place Details to get the full details of the address you are trying to search.
I tried the address in your Place Autocomplete request: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=1%20Lenin%20Avenue,%20Tomsk,%20Tomsk%20Oblast,%20Russia&strictbounds=true&location=56.488430,%2084.948047&radius=12285.769883&types=address&key=YOUR_KEY
the first result returned this place_id: ChIJE93JfarsJkMRQlvoCf2L0Tc
I used that place_id in my Place Details request: https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJE93JfarsJkMRQlvoCf2L0Tc&key=YOUR_KEY
And I was able to get this result including the street_number:
"address_components": [
{
"long_name": "1",
"short_name": "1",
"types": [
"street_number"
]
},
{
"long_name": "Lenin Avenue",
"short_name": "Lenin Ave",
"types": [
"route"
]
},
{
"long_name": "Tomsk",
"short_name": "Tomsk",
"types": [
"locality",
"political"
]
},
{
"long_name": "Tomsk",
"short_name": "Tomsk",
"types": [
"administrative_area_level_2",
"political"
]
},
{
"long_name": "Tomskaya oblast'",
"short_name": "Tomskaya oblast'",
"types": [
"administrative_area_level_1",
"political"
]
},
{
"long_name": "Russia",
"short_name": "RU",
"types": [
"country",
"political"
]
},
{
"long_name": "634028",
"short_name": "634028",
"types": [
"postal_code"
]
}
]
Upvotes: 2