[[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(...)
})

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

See [[LoaderOptions.id]]

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

  • Parameters

    • name: "core"

    Returns Promise<CoreLibrary>

  • Parameters

    • name: "maps"

    Returns Promise<MapsLibrary>

  • Parameters

    • name: "places"

    Returns Promise<PlacesLibrary>

  • Parameters

    • name: "geocoding"

    Returns Promise<GeocodingLibrary>

  • Parameters

    • name: "routes"

    Returns Promise<RoutesLibrary>

  • Parameters

    • name: "marker"

    Returns Promise<MarkerLibrary>

  • Parameters

    • name: "geometry"

    Returns Promise<GeometryLibrary>

  • Parameters

    • name: "elevation"

    Returns Promise<ElevationLibrary>

  • Parameters

    • name: "streetView"

    Returns Promise<StreetViewLibrary>

  • Parameters

    • name: "journeySharing"

    Returns Promise<JourneySharingLibrary>

  • Parameters

    • name: "drawing"

    Returns Promise<DrawingLibrary>

  • Parameters

    • name: "visualization"

    Returns Promise<VisualizationLibrary>

  • Parameters

    Returns Promise<unknown>

  • 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) => void)
        • (e): void
        • Parameters

          • e: ErrorEvent

          Returns void

    Returns void

Generated using TypeDoc