Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
load-google-maps-api
Advanced tools
A thin, Promise-returning helper for loading the Google Maps JavaScript API.
A thin, Promise-returning helper for loading the Google Maps JavaScript API.
google.maps
objectloadGoogleMapsApi().then(function (googleMaps) {
new googleMaps.Map(document.querySelector('.map'), {
center: {
lat: 40.7484405,
lng: -73.9944191
},
zoom: 12
})
}).catch(function (error) {
console.error(error)
})
N.B. Just like the Google Maps API itself, this module is client-side only.
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 = function () {
// `window.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 modern bundlers like Browserify or Webpack.
const loadGoogleMapsAPI = require('load-google-maps-api')
Returns a Promise.
google.maps
object.options.timeout
.See Usage.
options
is an optional object literal:
Key | Description | Default |
---|---|---|
channel | Client usage reporting channel | undefined |
client | Client ID | undefined |
key | Your API key | undefined |
language | Language | undefined |
libraries | Supplemental libraries to load | [] |
region | Region | undefined |
timeout | Time in milliseconds before rejecting the Promise | 10000 |
v | API version | undefined |
Install via yarn:
$ yarn add load-google-maps-api
Or npm:
$ npm install --save load-google-maps-api
1.1.0
prettier-standard
weight
scriptFAQs
A lightweight Promise-returning helper for loading the Google Maps JavaScript API
The npm package load-google-maps-api receives a total of 29,009 weekly downloads. As such, load-google-maps-api popularity was classified as popular.
We found that load-google-maps-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.