Google 个地方 API 个地方类型问题

Google Places API places types issue

我正在使用下面详述的代码来获取全球机场的自动完成文本字段,但它没有给出任何结果,但是,如果我将类型从机场更改为城市,它确实有效。

HTML:

<html>
<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="author" content="">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
    <script type="text/javascript" src="js/geo.js"></script>
</head>
<body>
    <div class="container">
        <div class="header"></div>
        <div id="nav-bar">
            <!-- <?php include ("nav-bar.php"); ?> -->
        </div>
        <div class="content">
            <div class="left-panel"></div>
            <div class="right-panel">
            <form action="">
                Origin:<br>
                <input type="text" name="" id="searchTextField"><br>
                Destination:<br>
                <input type="text" name=""><br>
                Departure:<br>
                <input type="date" name=""><br>
                Return:<br>
                <input type="date" name=""><br>                 
            </form>
            </div>
        </div>
        <div class="footer"></div>
    </div>
</body>

JS:

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);

支持的类型列表:https://developers.google.com/places/supported_types

非常感谢任何形式的帮助,并一如既往地提前感谢您花时间阅读本文。

没有 airport 地方类型。阅读更多相关信息 here

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.

要从地点 api 获取机场,您必须使用提及类型 airport 的 url。看到它 here