Tôi đã nhận thấy thông báo về việc Google không tham chiếu vì lợi ích của place_id
và đang tìm cách triển khai.API Google Địa điểm không trả lại place_id
Tôi đang sử dụng AutocompleteService
nhưng khi tôi chạy nó phản ứng không chứa place_id
, nhưng không chứa reference
và id
.
Đây là một sự thích nghi nhanh chóng tôi đã làm trong những trang ví dụ (tôi cố gắng đặt nó trên jsfiddle nhưng không thể làm cho nó chạy):
<!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>
Ai đó có thể giải thích những gì tôi đang mất tích/làm sai ?
Có ai đó có ví dụ về số AutocompleteService
với place_id
đang được trả về cùng với dự đoán/đề xuất không?
Cảm ơn
Cùng một điều ở đây: no place_id ... – thepit23
Cảm ơn bạn đã xác nhận. Nó sẽ là tốt để biết liệu Google đã quên về AutocompleteService trên bản đồ API hoặc cho dù họ vẫn còn trong quá trình implmenting place_id giá trị trên tất cả các hồ sơ. – user1116573