2014-06-25 85 views
7

我注意到Google關於棄用參考文件的消息,贊成place_id,並且正在尋求實施它。Google Places API未返回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被返回的預測/建議?

謝謝

回答

1

我可以確認你所看到的。我想我們只需要等待推出完成即可。

+0

同樣的事情:沒有place_id ... – thepit23

+0

感謝您的確認。最好知道Google是否忘記了地圖API上的AutocompleteService,或者他們是否仍在實施所有記錄上的place_id值。 – user1116573