File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -73,17 +73,24 @@ importLibrary("maps").then(({ Map }) => {
7373
7474If 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
8082import { setOptions , importLibrary } from " @googlemaps/js-api-loader" ;
8183
8284// Set the options for loading the API.
8385setOptions ({ key: " your-api-key-here" });
8486
87+ // Start loading the libraries needed for custom elements.
8588importLibrary (" maps" ); // needed for gmp-map
8689importLibrary (" 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
You can’t perform that action at this time.
0 commit comments