【问题标题】:Google Places API not returning place_idGoogle Places API 未返回 place_id
【发布时间】:2014-06-25 22:11:49
【问题描述】:

我注意到有关 Google 弃用引用以支持 place_id 的消息,并正在寻求实施它。

我正在使用AutocompleteService,但是当我运行它时,响应不包含place_id,但包含referenceid

这是我对示例页面所做的快速修改(我尝试将其放在 jsfiddle 上但无法运行):

<!DOCTYPE html>
<html>
<head>
<title>Retrieving Autocomplete Predictions</title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>
<script>
// This example retrieves autocomplete predictions programmatically
// from the autocomplete service, and displays them as an HTML list.
// The predictions will include a mix of places (as defined by the
// Google Places API) and suggested search terms.

function initialize() {
  var service = new google.maps.places.AutocompleteService();
  service.getQueryPredictions({ input: 'trafalgar square' }, callback);
}

function callback(predictions, status) {
  if (status != google.maps.places.PlacesServiceStatus.OK) {
    alert(status);
    return;
  }

  var results = document.getElementById('results');

  for (var i = 0, prediction; prediction = predictions[i]; i++) {
    results.innerHTML += '<li>' + prediction.description + '</li>';
  }
}

google.maps.event.addDomListener(window, 'load', initialize);

</script>

</head>
<body>
  <p>Query suggestions for 'trafalgar square':</p>
  <ul id="results"></ul>
</body>
</html>

谁能解释我错过了什么/做错了什么?

有人得到AutocompleteService 的示例,其中place_id 与预测/建议一起返回?

谢谢

【问题讨论】:

    标签: google-maps google-places-api


    【解决方案1】:
    【解决方案2】:

    我可以确认您所看到的。我想我们只需要等待部署完成即可。

    【讨论】:

    • 感谢您的确认。很高兴知道 Google 是否忘记了地图 API 上的 AutocompleteService,或者他们是否仍在对所有记录实施 place_id 值。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-02
    • 1970-01-01
    • 2016-10-01
    • 1970-01-01
    • 2018-07-14
    相关资源
    最近更新 更多