Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 599
ilse2005 Avatar asked Nov 21 '14 20:11

ilse2005


People also ask

Is Google places Autocomplete free?

The autocomplete request is available at no charge, and the subsequent Place Details call gets charged based on regular Place Details pricing. A Place Details request generates Data SKUs (Basic, Contact, and/or Atmosphere) – depending on the fields that are specified in the request.

How do I restrict Google Maps autocomplete to certain cities?

It is currently not possible to restrict results to a specific locality. You can use bounds as you have done so above to bias results towards, but not restricted to places contained within the specified bounds. If you believe restriction by locality would be a useful feature please file a Places API - Feature Request.

How do I use Google places API for location analysis and more?

Once you've made an account and are on the Google Cloud platform, you'll want to go to use the drop down navigation in the top left and choose API & Services > Credentials. Once there, you'll want to hit Create Credentials on the top followed by API key.


1 Answers

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

like image 173
MrUpsidown Avatar answered Sep 20 '22 18:09

MrUpsidown