Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.