Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

load-google-maps-api

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

load-google-maps-api - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

4

CHANGELOG.md
# Changelog
## 1.3.0
- Return `google.maps` if previously-loaded
## 1.2.0

@@ -4,0 +8,0 @@

15

index.js

@@ -9,9 +9,14 @@ var CALLBACK_NAME = '__googleMapsApiOnLoadCallback'

return new Promise(function (resolve, reject) {
// Reject the promise after a timeout.
// Check if the Google Maps API has already been loaded
if (window.google && window.google.maps) {
return resolve(window.google.maps)
}
// Reject the promise after a timeout
var timeoutId = setTimeout(function () {
window[CALLBACK_NAME] = function () {} // Set the on load callback to a no-op.
window[CALLBACK_NAME] = function () {} // Set the on load callback to a no-op
reject(new Error('Could not load the Google Maps API'))
}, options.timeout || 10000)
// Hook up the on load callback.
// Hook up the on load callback
window[CALLBACK_NAME] = function () {

@@ -25,3 +30,3 @@ if (timeoutId !== null) {

// Prepare the `script` tag to be inserted into the page.
// Prepare the `script` tag to be inserted into the page
var scriptElement = document.createElement('script')

@@ -40,5 +45,5 @@ var params = ['callback=' + CALLBACK_NAME]

// Insert the `script` tag.
// Insert the `script` tag
document.body.appendChild(scriptElement)
})
}
{
"name": "load-google-maps-api",
"version": "1.2.1",
"version": "1.3.0",
"description": "A thin, Promise-returning helper for loading the Google Maps JavaScript API.",

@@ -15,2 +15,3 @@ "author": "Lim Yuan Qing",

"prettier-standard": "^8.0.0",
"rimraf": "^2.6.2",
"standard": "^11.0.1",

@@ -22,3 +23,3 @@ "tape": "^4.9.0",

"scripts": {
"clean": "rm -rf *.log",
"clean": "rimraf '*.log'",
"fix": "prettier-standard '*.js'",

@@ -25,0 +26,0 @@ "lint": "standard '*.js'",

@@ -7,3 +7,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)

- Optionally set a timeout, an API key, the language, [and more](#loadgooglemapsapioptions)
- 414 bytes gzipped
- 429 bytes gzipped

@@ -57,3 +57,3 @@ ## Usage

- **Fulfilled** if loading was successful. The fulfilled callback is passed the `google.maps` object.
- **Fulfilled** if loading was successful. The fulfilled callback is passed the `google.maps` object. If `loadGoogleMapsApi` is called multiple times on a page, the fulfilled callback will be passed the previously-loaded `google.maps` object.
- **Rejected** if we weren’t able to load the Google Maps API after `options.timeout`.

@@ -60,0 +60,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc