Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niksy/fetch-google-maps
Load Google Maps API.
https://github.com/niksy/fetch-google-maps
Last synced: 7 days ago
JSON representation
Load Google Maps API.
- Host: GitHub
- URL: https://github.com/niksy/fetch-google-maps
- Owner: niksy
- License: mit
- Created: 2014-08-02T16:33:55.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-04-18T08:40:38.000Z (over 7 years ago)
- Last Synced: 2024-10-18T03:47:35.394Z (28 days ago)
- Language: JavaScript
- Homepage:
- Size: 34.2 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# fetch-google-maps
[![Build Status][ci-img]][ci] [![BrowserStack Status][browserstack-img]][browserstack]
Load [Google Maps API][google-maps-api].
## Install
```sh
npm install fetch-google-maps --save
```## Usage
```js
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**[Google API key](https://developers.google.com/maps/documentation/javascript/get-api-key).
##### version
Type: `Number`
Default: `3`[Google Maps API version](https://developers.google.com/maps/documentation/javascript/versions).
##### language
Type: `String`
Default: `'en'`[Language](https://developers.google.com/maps/documentation/javascript/localization) for Google Maps UI.
##### libraries
Type: `String[]`
List of [Google Maps libraries](https://developers.google.com/maps/documentation/javascript/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 in your browser.
## Browser support
Tested in IE9+ and all modern browsers. Uses Promises so you need to apply [polyfill][promise-polyfill].
## Acknowledgments
* Wrapper around [basic Google Maps fetching][basic-google-maps-fetching].
## License
MIT © [Ivan Nikolić](http://ivannikolic.com)
[ci]: https://travis-ci.org/niksy/fetch-google-maps
[ci-img]: https://travis-ci.org/niksy/fetch-google-maps.svg?branch=master
[browserstack]: https://www.browserstack.com/
[browserstack-img]: https://www.browserstack.com/automate/badge.svg?badge_key=RGhpWUE4L2ZEeFlJK3c2MEczYmFmOVUzTExqY3VaVDFaVkZyZjRCbFBGUT0tLUJlRUhiajBpS1VGZFNFaU1XdVRKU2c9PQ==--d2f9e67e34833c7263b15c40b6e3a56ce5772cbd
[basic-google-maps-fetching]: https://gist.github.com/GFoley83/5953448
[promise-polyfill]: https://github.com/calvinmetcalf/lie
[google-maps-api]: https://developers.google.com/maps/documentation/javascript/tutorial