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

A thin, Promise-returning helper for loading the Google Maps JavaScript API.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
35K
increased by3.21%
Maintainers
1
Weekly downloads
 
Created
Source

load-google-maps-api npm Version Build Status

A thin, Promise-returning helper for loading the Google Maps JavaScript API.

Usage

import loadGoogleMapsAPI from 'load-google-maps-api';

loadGoogleMapsAPI().then((googleMaps) => {
  console.log(googleMaps); //=> Object { Animation: Object, ...
}).catch((err) => {
  console.error(err);
});

Read the source to understand how this works.

N.B. Just like the Google Maps API itself, this module is client-side only.

Why

Without this module, you would need to specify a named global callback, and pass said callback’s name as a parameter in the script tag’s src. For example:

<script>
window.googleMapsOnLoad = () => {
  // `google.maps` available here
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?callback=googleMapsOnLoad"></script>

This module abstracts this ceremony away, and fits better with Browserify or Webpack.

API

import loadGoogleMapsAPI from 'load-google-maps-api';

loadGoogleMapsAPI([opts])

Returns a Promise.

  • Fulfilled if load was successful. The fulfilled callback is passed the google.maps object.
  • Rejected if we weren’t able to load the Google Maps API after opts.timeout.

opts is an object literal:

KeyDescriptionDefault
librariesSupplemental libraries to load[]
keyYour API keyundefined
clientThe client IDundefined
vAPI versionundefined
timeoutTime in milliseconds before rejecting the promise10000

Installation

Install via npm:

$ npm i --save load-google-maps-api

License

MIT

FAQs

Package last updated on 01 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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