@googlemaps/js-api-loader

    Class Loader

    [[Loader]] makes it easier to add Google Maps JavaScript API to your application dynamically using Promises. It works by dynamically creating and appending a script node to the the document head and wrapping the callback function so as to return a promise.

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

    loader.load().then((google) => {
    const map = new google.maps.Map(...)
    })
    Index

    Constructors

    • Creates an instance of Loader using [[LoaderOptions]]. No defaults are set using this library, instead the defaults are set by the Google Maps JavaScript API server.

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

      Parameters

      Returns Loader

    Properties

    apiKey: string

    See [[LoaderOptions.apiKey]]

    authReferrerPolicy: "origin"

    See [[LoaderOptions.authReferrerPolicy]]

    channel: string

    See [[LoaderOptions.channel]]

    client: string

    See [[LoaderOptions.client]]

    id: string
    language: string

    See [[LoaderOptions.language]]

    libraries: Libraries

    See [[LoaderOptions.libraries]]

    mapIds: string[]

    See [[LoaderOptions.mapIds]]

    nonce: string

    See [[LoaderOptions.nonce]]

    region: string

    See [[LoaderOptions.region]]

    retries: number

    See [[LoaderOptions.retries]]

    url: string

    See [[LoaderOptions.url]]

    version: string

    See [[LoaderOptions.version]]

    Accessors

    Methods

    • Load the Google Maps JavaScript API script and return a Promise. @deprecated, use importLibrary() instead.

      Returns Promise<typeof google>

    • Load the Google Maps JavaScript API script with a callback. @deprecated, use importLibrary() instead.

      Parameters

      • fn: (e: ErrorEvent) => void

      Returns void

    MMNEPVFCICPMFPCPTTAAATR