谷歌地点API没有返回place_id

9
我注意到了关于谷歌弃用reference而采用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>

有人能解释一下我缺少什么/做错了什么吗?

有人有使用AutocompleteServiceplace_id一起返回预测/建议的示例吗?

谢谢

2个回答


1
我可以确认你看到的内容。我猜我们只需要等待推出完成即可。

感谢确认。了解Google是否已经忘记了地图API上的AutocompleteService,还是他们仍在将place_id值实现在所有记录中会很有帮助。 - user1116573

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接