load-google-maps-api
Advanced tools
Comparing version 0.0.1 to 0.0.2
14
index.js
export default ({ | ||
client, | ||
key, | ||
language, | ||
libraries = [], | ||
key, | ||
client, | ||
timeout = 10000, | ||
v, | ||
timeout = 10000 | ||
} = {}) => { | ||
@@ -21,6 +22,7 @@ | ||
const params = ['callback=' + callbackName]; | ||
libraries = [].concat(libraries); // Ensure that `libaries` is an array | ||
if (client) params.push('client=' + client); | ||
if (key) params.push('key=' + key); | ||
if (language) params.push('language=' + language); | ||
libraries = [].concat(libraries); // Ensure that `libraries` is an array | ||
if (libraries.length) params.push('libraries=' + libraries.join(',')); | ||
if (key) params.push('key=' + key); | ||
if (client) params.push('client=' + client); | ||
if (v) params.push('v=' + v); | ||
@@ -27,0 +29,0 @@ scriptElement.src = 'https://maps.googleapis.com/maps/api/js?' + params.join('&'); |
@@ -10,9 +10,10 @@ 'use strict'; | ||
var client = _ref.client; | ||
var key = _ref.key; | ||
var language = _ref.language; | ||
var _ref$libraries = _ref.libraries; | ||
var libraries = _ref$libraries === undefined ? [] : _ref$libraries; | ||
var key = _ref.key; | ||
var client = _ref.client; | ||
var v = _ref.v; | ||
var _ref$timeout = _ref.timeout; | ||
var timeout = _ref$timeout === undefined ? 10000 : _ref$timeout; | ||
var v = _ref.v; | ||
@@ -31,6 +32,7 @@ var callbackName = '__googleMapsApiOnLoadCallback'; | ||
var params = ['callback=' + callbackName]; | ||
libraries = [].concat(libraries); // Ensure that `libaries` is an array | ||
if (client) params.push('client=' + client); | ||
if (key) params.push('key=' + key); | ||
if (language) params.push('language=' + language); | ||
libraries = [].concat(libraries); // Ensure that `libraries` is an array | ||
if (libraries.length) params.push('libraries=' + libraries.join(',')); | ||
if (key) params.push('key=' + key); | ||
if (client) params.push('client=' + client); | ||
if (v) params.push('v=' + v); | ||
@@ -37,0 +39,0 @@ scriptElement.src = 'https://maps.googleapis.com/maps/api/js?' + params.join('&'); |
{ | ||
"name": "load-google-maps-api", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A thin, Promise-returning helper for loading the Google Maps JavaScript API.", | ||
@@ -5,0 +5,0 @@ "author": "Lim Yuan Qing", |
@@ -44,3 +44,3 @@ # load-google-maps-api [![npm Version](http://img.shields.io/npm/v/load-google-maps-api.svg?style=flat)](https://www.npmjs.com/package/load-google-maps-api) [![Build Status](https://img.shields.io/travis/yuanqing/load-google-maps-api.svg?branch=master&style=flat)](https://travis-ci.org/yuanqing/load-google-maps-api) | ||
Returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). | ||
Returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). (See [Usage](#usage).) | ||
@@ -50,11 +50,12 @@ - **Fulfilled** if load was successful. The fulfilled callback is passed the `google.maps` object. | ||
`opts` is an object literal: | ||
`opts` is an optional object literal: | ||
Key | Description | Default | ||
:--|:--|:-- | ||
`libraries` | [Supplemental libraries to load]((https://developers.google.com/maps/documentation/javascript/libraries)) | `[]` | ||
`client` | [Client ID](https://developers.google.com/maps/documentation/javascript/get-api-key#specify-a-client-id-when-loading-the-api) | `undefined` | ||
`key` | [Your API key](https://developers.google.com/maps/documentation/javascript/get-api-key#specify-a-key-when-loading-the-api) | `undefined` | ||
`client` | [The client ID]((https://developers.google.com/maps/documentation/javascript/get-api-key#specify-a-client-id-when-loading-the-api)) | `undefined` | ||
`v` | [API version]((https://developers.google.com/maps/documentation/javascript/versions)) | `undefined` | ||
`timeout` | Time in milliseconds before rejecting the promise | 10000 | ||
`language` | [Language](https://developers.google.com/maps/documentation/javascript/examples/map-rtl) | `undefined` | ||
`libraries` | [Supplemental libraries to load](https://developers.google.com/maps/documentation/javascript/libraries) | `[]` | ||
`timeout` | Time in milliseconds before rejecting the promise | `10000` | ||
`v` | [API version](https://developers.google.com/maps/documentation/javascript/versions) | `undefined` | ||
@@ -61,0 +62,0 @@ ## Installation |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11133
140
71