ilse2005
ilse2005

Reputation: 11439

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?

Upvotes: 5

Views: 8734

Answers (2)

MrUpsidown
MrUpsidown

Reputation: 22497

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. For a list of supported types, see the developer's guide. 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.

Types supported in place autocomplete requests

Upvotes: 4

Pbrain19
Pbrain19

Reputation: 2118

In order to accomplish this you can use the airport type for google place searches. Then use the results to implement your own autocomplete dropdown. Autocomplete does not support it at the time (https://developers.google.com/places/supported_types) but places search does.

Upvotes: 3

Related Questions