@@ -72,24 +72,23 @@ importLibrary("maps").then(({ Map }) => {
7272```
7373
7474If you use custom HTML elements from the Google Maps JavaScript API (e.g.
75- ` <gmp-map> ` , and ` <gmp-advanced-marker> ` ), you need to import them as well:
75+ ` <gmp-map> ` , and ` <gmp-advanced-marker> ` ), you need to import them as well.
76+ Note that you do not need to await the result of importLibrary in this case.
77+ The custom elements will upgrade automatically once the library is loaded.
7678
7779``` javascript
7880import { setOptions , importLibrary } from " @googlemaps/js-api-loader" ;
7981
8082// Set the options for loading the API.
8183setOptions ({ key: " your-api-key-here" });
8284
83- await importLibrary (" maps" ); // needed for gmp-map
84- await importLibrary (" marker" ); // needed for gmp-advanced-marker
85-
86- // Or:
87- await Promise .all ([importLibrary (" maps" ), importLibrary (" marker" )]);
85+ importLibrary (" maps" ); // needed for gmp-map
86+ importLibrary (" marker" ); // needed for gmp-advanced-marker
8887```
8988
9089## Documentation
9190
92- This package exports just two functions, ` setOptions ` and ` importLibrary ` .
91+ This package exports just two functions, ` setOptions() ` and ` importLibrary() ` .
9392
9493``` ts
9594// Using named exports:
@@ -120,7 +119,7 @@ Below is a short summary of the accepted options, see the
120119- ` authReferrerPolicy: string ` : Set the referrer policy for the API requests.
121120- ` mapIds: string[] ` : An array of map IDs to preload.
122121- ` channel: string ` : Can be used to track your usage.
123- - ` solutionChannel: string ` : Used by the Google Maps Platform to track
122+ - ` solutionChannel: string ` : Used by the Google Maps Platform to track
124123 adoption and usage of examples and solutions.
125124
126125### ` importLibrary(library: string): Promise `
@@ -130,7 +129,7 @@ library object when the library is loaded. In case of an error while loading
130129the library (might be due to poor network conditions and other unforseeable
131130circumstances), the promise is rejected with an error.
132131
133- Calling this function for the first time will trigger loading the Google
132+ Calling this function for the first time will trigger loading the Google
134133Maps JavaScript API itself.
135134
136135The following libraries are available:
0 commit comments