Skip to content

Commit 83cc7e1

Browse files
committed
get functioning pop-up InfoWindow for google maps to work
1 parent e5a2ead commit 83cc7e1

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎examples/config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export function createMarker(map: google.maps.Map, lat: number, lng: number) {
6666
map,
6767
position: { lat, lng },
6868
gmpClickable: true,
69+
title: `i'm a chump and`,
6970
});
7071
}
7172

‎examples/defaults.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,24 @@ new Loader(getLoaderOptions()).load().then(() => {
3030

3131
const map = new google.maps.Map(element, mapOptions);
3232

33+
const myWindow = new google.maps.InfoWindow();
34+
3335
const markers = trees.map(({ geometry }) =>
3436
createMarker(map, geometry.coordinates[1], geometry.coordinates[0])
3537
);
3638

39+
// markers.forEach((marker) => console.log(marker));
40+
41+
// now, iterate through that list of markers and make an event listener for each of them
42+
markers.forEach((marker) => {
43+
marker.addListener("click", ({ domEvent, latLng }) => {
44+
const { target } = domEvent;
45+
myWindow.close();
46+
myWindow.setContent(marker.title);
47+
myWindow.open(marker.map, marker);
48+
});
49+
});
50+
3751
const markerCluster = new MarkerClusterer({
3852
markers,
3953
});

0 commit comments

Comments
 (0)