/
index.js
33 lines (29 loc) · 885 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @license
* Copyright 2019 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
// [START maps_web_components_events]
// This example adds a map using web components.
function initMap() {
console.log("Maps JavaScript API loaded.");
const advancedMarkers = document.querySelectorAll(
"#marker-click-event-example gmp-advanced-marker",
);
for (const advancedMarker of advancedMarkers) {
customElements.whenDefined(advancedMarker.localName).then(async () => {
advancedMarker.addEventListener("gmp-click", async () => {
const infoWindow = new google.maps.InfoWindow({
//@ts-ignore
content: advancedMarker.title,
});
infoWindow.open({
//@ts-ignore
anchor: advancedMarker,
});
});
});
}
}
window.initMap = initMap;
// [END maps_web_components_events]