Skip to content

niksy/fetch-google-maps

Repository files navigation

fetch-google-maps

Build Status BrowserStack Status

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

Google API key.

version

Type: Number
Default: 3

Google Maps API version.

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

License

MIT © Ivan Nikolić