Google Maps JavaScript API v3
Feedback on this document

Accessing Autocomplete query suggestions

View this example full screen.

JavaScript
function initialize() {
  var service = new google.maps.places.AutocompleteService();
  service.getQueryPredictions({ input: 'pizza near' }, 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);
JavaScript + HTML
<!DOCTYPE html>
<html>
<head>
<title>Accessing Autocomplete query suggestions</title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true&libraries=places&v=3.exp"></script>
<script>
function initialize() {
  var service = new google.maps.places.AutocompleteService();
  service.getQueryPredictions({ input: 'pizza near' }, 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 'Pizza near':</p>
  <ul id="results"></ul>
</body>
</html>

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.