Google Places Javascript Autocomplete (Partial place name search)

August 24, 2018
Autocomplete.getPlacePredictions

Get API Key and Include Javascript for Google Map/Places.

const autocompleteService = new google.maps.places.AutocompleteService()

const autocompleteRequest = {
  input: 'ja', // trying autocomplete for "japan"
}

autocompleteService.getPlacePredictions(autocompleteRequest, (results, status) => {
  if (status == google.maps.places.PlacesServiceStatus.OK) {
    results.forEach((item) => {
      console.log(item.description)
    })
  }
})

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.