Using google place to auto fill an input

I have an input that links to a google map. The input acts as a search that locates the address typed in the input on the map and places a google maps marker. Is it possible to have that input auto-complete/auto suggest what you are typing using the google places api. The input is currently set to and Address Type.

Do you want addresses, or Google places ? We can autocomplete on the former, but you can’t directly do this via the Place API with Places.

Places aren’t addresses though, although sometimes they do look like there is crossover.

Potentially you could pull back a list of google places within a particular radius, and use a dynamic search on this but you would need to store it on the database to do that.

What is it you want to show on the map ?

1 Like

Its the auto complete of address i would like. Such as if you search on the actual google maps site it opens a drop down that guesses your input.

Joe

1 Like

What the google places api can do is to auto-complete the address (as a default value for the address input) when you are filing the name of a place (if it is listed in google places it will work) in another input. I’m using it like this for my app and it Works perfect. Hope it helps :wink:

3 Likes

Hi Diego,

Could you please elaborate a bit more on how i would implement this.

Thanks for the advice.

Joe

You need two inputs: one type text for the name, and another type address.
For the address input you set the initial content to do a search using the google places api , and you just need to set the Query as your text input:

The user can then modify the initial value if needed.
From my experience if you put the name of a place + name of the city it gives you the right address almost always

2 Likes

Yes, that would give you a list of addresses that happen to have a google place for that search.

If you want a list of ALL addresses, that is a different thing as not all Addresses have Places, and some addresses have multiple Places.

If you want “Pubs In London” to return you all addresses of pubs in London … then that is great. If you want to search for way, “Upper Thames Street” (as a guess this isn’t a place but it is an address) then you won’t get the address back. For that you need the goegraphic address search.

All depends on what you are trying to do :slightly_smiling:

Its the latter that im trying to do Nigel. So i would need to use a geographical search box? Would this need to be linked to google places at all?

Joe

No, not at all. If you want a normal address, then use the search box and set to geographic address.

You don’t need Places unless you want Places rather than pure addresses.

Not disagreeing with Diego, just trying to understand what it is you are after, his use case may well be different and is perfectly valid.

1 Like

Thanks guys, i managed to get it to work thanks to you both!!

3 Likes

Hi Friend, I am trying to do exactly the same thing. Would you be able to explain with snapshots how you achieved this please?