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

@googlemaps/js-api-loader

Package Overview
Dependencies
Maintainers
2
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@googlemaps/js-api-loader

Wrapper for the loading of Google Maps JavaScript API script in the browser

  • 1.12.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
723K
decreased by-54.49%
Maintainers
2
Weekly downloads
 
Created

What is @googlemaps/js-api-loader?

The @googlemaps/js-api-loader package is a lightweight JavaScript library that simplifies the loading of the Google Maps JavaScript API into web pages. It provides a promise-based API to load the Google Maps API dynamically, handling the insertion of the script tag and optional configuration settings.

What are @googlemaps/js-api-loader's main functionalities?

Loading the Google Maps JavaScript API

This code sample demonstrates how to load the Google Maps JavaScript API using the @googlemaps/js-api-loader. It initializes a new Loader instance with an API key, version, and additional libraries, then loads the API and creates a map instance.

const { Loader } = require('@googlemaps/js-api-loader');

const loader = new Loader({
  apiKey: 'YOUR_API_KEY',
  version: 'weekly',
  libraries: ['places']
});

loader.load().then(() => {
  const map = new google.maps.Map(document.getElementById('map'), {
    center: { lat: -34.397, lng: 150.644 },
    zoom: 8
  });
});

Setting additional configuration options

This code sample shows how to set additional configuration options such as language and region when loading the Google Maps JavaScript API.

const loader = new Loader({
  apiKey: 'YOUR_API_KEY',
  version: 'weekly',
  libraries: ['places'],
  language: 'en',
  region: 'US'
});

loader.load().then(() => {
  // Google Maps API is ready to use
});

Other packages similar to @googlemaps/js-api-loader

Keywords

FAQs

Package last updated on 06 Oct 2021

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