google-maps-js-api-loader
Description
Async loader for google maps api
Example
import Loader from "google-maps-js-api-loader";
await Loader.load({
apiKey: API_KEY,
});
Loader.load({
apiKey: API_KEY,
});
await Loader.completion;
API
load
async static load(options: LoaderOptions, onLoadingStart?: () => void): Promise<void>
Asynchronously loads Google Maps JavaScript API with given options, can be called multiple times, but always returns promise from the first call
Note: it throws an error if google.maps already exists on the first call or if the options are different from the first call
status
enum LoaderStatus {
NONE,
LOADING,
LOADED,
ERROR,
}
static status: LoaderStatus
Current status of Loader
completion
static completion: Promise<void>
Promise from load first call
libraries
static libraries: Libraries
List of libraries from options
LoaderOptions
Options structure is similar to @googlemaps/js-api-loader
License
MIT © Krombik