google-maps-js-api-loader
Description
Async loader for google maps api
Example
import Loader from "google-maps-js-api-loader";
Loader.options = {
apiKey: API_KEY,
};
await Loader.load();
API
options
static options: LoaderOptions
Loader options (query parameters for script url and some script attributes), should be set before load execution
load
async static load(): Promise<void>
Starts loading of Google Maps JavaScript API with given options (if it not loaded yet), returns completion
throws error if google.maps already loaded by something else or if no options was provided
status
enum LoaderStatus {
NONE,
LOADING,
LOADED,
ERROR,
}
static status: LoaderStatus
Current status of Loader
completion
static completion: Promise<void>
Promise of loading, it has pending status even if load not called yet (can be useful if you want to do something after loading done, but don't want to start loading)
License
MIT © Krombik