ilse2005 ilse2005 - 5 months ago 209
Javascript Question

Google Places autocomplete for Airports

I am trying to build an auto-complete for airports using Googles auto-complete places API.
I found the following code in an question here, but it returns no results:
Setting Google Places 'Types' on Dropdown Input

<script type="text/javascript">
function initialize()
{
var input = document.getElementById('searchTextField');
var options = {
types: ['airport'],

};

autocomplete = new google.maps.places.Autocomplete(input, options);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
<input id="searchTextField" type="text" size="50" placeholder="Search for an Airport!">


Can anyone help me?

Answer

There is no airport place type.

https://developers.google.com/maps/documentation/javascript/reference#AutocompleteOptions

types | Array.<string>

The types of predictions to be returned. Four types are supported: 'establishment' for businesses, 'geocode' for addresses, '(regions)' for administrative regions and '(cities)' for localities. If nothing is specified, all types are returned. In general only a single type is allowed. The exception is that you can safely mix the 'geocode' and 'establishment' types, but note that this will have the same effect as specifying no types.