fetch-google-maps
v2.0.1
Published
Load Google Maps API.
Downloads
28
Readme
fetch-google-maps
Load Google Maps API.
Install
npm install fetch-google-maps --save
Usage
const fetchGoogleMaps = require('fetch-google-maps');
fetchGoogleMaps({
apiKey: 'YOUR_GOOGLE_API_KEY',
language: 'en',
libraries: ['geometry']
}).then(( Maps ) => {
const map = new Maps.Map(document.getElementById('map'), {
zoom: 8,
center: new Maps.LatLng(-34.397, 150.644)
});
});
API
fetchGoogleMaps(options)
Returns: Promise
options
Type: Object
apiKey
Type: String
Required
version
Type: Number
Default: 3
language
Type: String
Default: 'en'
Language for Google Maps UI.
libraries
Type: String[]
List of Google Maps libraries to load.
Test
You need to have process variable OSS_GOOGLE_API_KEY
set.
For local automated tests, run npm run test:automated:local
.
For manual tests, run npm run test:manual:local
and open http://localhost:9000/ in your browser.
Browser support
Tested in IE9+ and all modern browsers. Uses Promises so you need to apply polyfill.
Acknowledgments
- Wrapper around basic Google Maps fetching.
License
MIT © Ivan Nikolić