admin管理员组

文章数量:1297026

I am trying to build an auto-plete for airports using Googles auto-plete 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'],

  };

  autoplete = new google.maps.places.Autoplete(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?

I am trying to build an auto-plete for airports using Googles auto-plete 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'],

  };

  autoplete = new google.maps.places.Autoplete(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?

Share Improve this question edited May 23, 2017 at 10:30 CommunityBot 11 silver badge asked Nov 21, 2014 at 20:37 ilse2005ilse2005 11.4k5 gold badges55 silver badges75 bronze badges 2
  • Seems this is known issues code.google./p/gmaps-api-issues/issues/detail?id=7126 – Alex Filatov Commented Nov 21, 2014 at 21:00
  • Thank you. I hope they will fix this soon. I will keep this thread updated. – ilse2005 Commented Nov 21, 2014 at 23:21
Add a ment  | 

2 Answers 2

Reset to default 4

There is no airport place type.

https://developers.google./maps/documentation/javascript/reference#AutopleteOptions

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 autoplete requests

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

本文标签: javascriptGoogle Places autocomplete for AirportsStack Overflow