Skip to content

Instantly share code, notes, and snippets.

@webdesignberlin
Created September 6, 2017 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdesignberlin/2ed5c33d43ea62b704c12986e2fcd8d5 to your computer and use it in GitHub Desktop.
Save webdesignberlin/2ed5c33d43ea62b704c12986e2fcd8d5 to your computer and use it in GitHub Desktop.
mapsresolve
export const getSuggestions = (input) => {
return new Promise((resolve, reject) => {
const empty = input.length < 3 || !window || !window.google || !window.google.maps
if (empty) resolve([])
try {
const service = new window.google.maps.places.AutocompleteService()
service.getQueryPredictions({ input }, (suggestions) => {
resolve(suggestions || [])
})
} catch (e) {
reject(e)
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment