Created
September 6, 2017 14:53
-
-
Save webdesignberlin/2ed5c33d43ea62b704c12986e2fcd8d5 to your computer and use it in GitHub Desktop.
mapsresolve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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