Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google places API to get airport names in autocomplete

I am using google places Api. I want to have only the airports of particular country to displayed by autocomplete api. Is there any way to achieve this?

like image 338
srisindhu saride Avatar asked Nov 09 '22 08:11

srisindhu saride


1 Answers

For a place search, you can apply a type filter from within a predefined list (airport included): https://developers.google.com/places/supported_types

The place search doesn't allow country filtering (it uses latlng + radius params instead), but using the country name as the query term should yield the correct results.

https://maps.googleapis.com/maps/api/place/textsearch/json?query=Australia&key=addkeyhere&type=airport

However, this doesn't apply to the autocomplete API so you'll probably want to grab the full text search result, cache them client-side and do your own matching/autocomplete.

like image 63
Matt O Avatar answered Nov 15 '22 04:11

Matt O