Contents

load(libraryNames)

Tells MapKit JS which libraries to load.

Declaration

load?(libraryNames: string | string[]): Promise<MapKit>;

Parameters

  • libraryNames:

    The libraries to load.

Mentioned in

Return Value

A promise that resolves when the libraries finish loading. The promise resolves to the mapkit namespace object.

Discussion

This method returns a Promise that resolves when the requested libraries finish loading. The promise resolves to the mapkit namespace object, allowing you to destructure the interfaces you need directly from the result:

const { Map } = await mapkit.load(["map"]);

MapKit JS also dispatches either a load event or a load-error event when the libraries finish loading. The event (MapKitLibraryLoadEvent) contains the array of library names that you pass to this method. If the libraries fail to load, the returned promise rejects.

Calling load() with libraries that are already loaded is a no-op; the promise resolves immediately.

See Also

Initialization