Skip to content

Commit 8d15fc3

Browse files
committed
docs: update readme
1 parent c11fd94 commit 8d15fc3

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,24 @@ importLibrary("maps").then(({ Map }) => {
7373

7474
If you use custom HTML elements from the Google Maps JavaScript API (e.g.
7575
`<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.
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
78+
and you can use the `whenDefined()` method to wait for the upgrade to
79+
complete.
7880

7981
```javascript
8082
import { setOptions, importLibrary } from "@googlemaps/js-api-loader";
8183

8284
// Set the options for loading the API.
8385
setOptions({ key: "your-api-key-here" });
8486

87+
// Start loading the libraries needed for custom elements.
8588
importLibrary("maps"); // needed for gmp-map
8689
importLibrary("marker"); // needed for gmp-advanced-marker
90+
91+
// Wait for the map-componment to be upgraded
92+
const map = document.querySelector("gmp-map");
93+
await map.whenDefined();
8794
```
8895

8996
## Documentation

0 commit comments

Comments
 (0)