Created
September 13, 2017 21:58
-
-
Save cassaram09/58da6c6658077b1df0319d8519b348c9 to your computer and use it in GitHub Desktop.
tool to load Google Maps API
This file contains hidden or 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
import load from "little-loader"; | |
import qs from "query-string"; | |
// YOUR_API_KEY - string | |
// libraries - array of strings, eg ['places'] | |
const loadGoogleMaps = (YOUR_API_KEY, libraries) => { | |
return new Promise( (resolve, reject) => { | |
var params = {key: YOUR_API_KEY, libraries: libraries} | |
load(`https://maps.googleapis.com/maps/api/js?${qs.stringify(params)}`, (error) => { | |
if (error) { | |
reject("Unable to load Google Maps"); | |
} else { | |
console.log('Google Maps loaded.') | |
resolve(); | |
} | |
}) | |
}) | |
} | |
export default loadGoogleMaps; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment