Description
The Google Maps JavaScript API Loader is an npm package that loads the Google Maps JavaScript API script dynamically. It is an npm version of Google's Dynamic Library Import script, so you can load the Maps API from your JavaScript or TypeScript code instead of adding a script tag by hand. The package exports two functions. setOptions sets your API key and loading options, such as the version, language and region, and installs the global importLibrary function. importLibrary then loads the parts of the Maps API that you need. Call setOptions once, as early as possible in the app, because later calls have no effect and log a warning. Custom HTML elements from the Maps API can also be imported, and they upgrade automatically once the library loads. You can use whenDefined to wait for that upgrade. To use the package, you need a Google Cloud project with the Maps JavaScript API enabled, and an API key for that project. TypeScript users should also install the type definitions for the Maps API. It suits developers who add Google Maps to a web app and want to load it on demand.…
Highlights
- Loads the Maps JavaScript API dynamically
- setOptions and importLibrary functions
- TypeScript type definitions available
- Support for custom Maps HTML elements
- Needs a Google Cloud project and API key
Ratings & Reviews
No ratings yet
Be the first to rate JS API Loader.
People also visit
JS API Loader FAQ
What does it do?
It loads the Google Maps JavaScript API script for you, through an npm package.
What do I need before using it?
A Google Cloud project with the Maps JavaScript API enabled, and an API key for that project.
How do I call it?
Call setOptions once with your key, then use importLibrary to load the parts of the Maps API you need.
Does it work with TypeScript?
Yes. Install the Maps type definitions alongside the package.
Can I wait for custom elements?
Yes. Use whenDefined to wait for a custom Maps element to upgrade after the library loads.
What are the best JS API Loader alternatives?
Popular alternatives to JS API Loader include docker-staticmaps, React Map GL and RankMap Pro - Lifetime Access. See all JS API Loader alternatives











