【问题标题】:Google Places autocomplete for Airports机场的 Google 地方信息自动填充功能
【发布时间】:2015-01-20 02:30:00
【问题描述】:

我正在尝试使用 Google 的自动完成地点 API 为机场构建一个自动完成功能。 我在这里的一个问题中找到了以下代码,但它没有返回任何结果: 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!">

谁能帮帮我?

【问题讨论】:

标签: javascript google-maps-api-3 google-places-api


【解决方案1】:

没有airport 地点类型。

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

types | Array.&lt;string&gt;

要返回的预测类型。有关受支持类型的列表,请参阅开发人员指南。如果未指定任何内容,则返回所有类型。通常只允许使用一种类型。例外情况是您可以安全地混合使用 'geocode' 和 'establishment' 类型,但请注意,这与不指定类型具有相同的效果。

Types supported in place autocomplete requests

【讨论】:

    【解决方案2】:

    为了做到这一点,您可以使用机场类型进行 google 地方搜索。然后使用结果来实现您自己的自动完成下拉菜单。自动完成当时不支持它 (https://developers.google.com/places/supported_types),但地点搜索支持。

    【讨论】:

      猜你喜欢
      • 2015-08-05
      • 2020-08-04
      • 2013-12-09
      • 2016-01-30
      • 2012-04-27
      • 2023-03-12
      • 1970-01-01
      • 1970-01-01
      • 2014-03-28
      相关资源
      最近更新 更多