Skip to content

Commit bee22c8

Browse files
Update dist folder [skip ci] (#1157)
1 parent 242fcac commit bee22c8

21 files changed

Lines changed: 591 additions & 1 deletion

dist/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ <h1>Maps JSAPI Samples</h1>
7171
<li><a href='/samples/deckgl-kml/dist'>deckgl-kml</a></li>
7272
<li><a href='/samples/deckgl-kml-updated/dist'>deckgl-kml-updated</a></li>
7373
<li><a href='/samples/deckgl-polygon/dist'>deckgl-polygon</a></li>
74+
<li><a href='/samples/event-poi/dist'>event-poi</a></li>
7475
<li><a href='/samples/geocoding-reverse/dist'>geocoding-reverse</a></li>
7576
<li><a href='/samples/geocoding-simple/dist'>geocoding-simple</a></li>
7677
<li><a href='/samples/js-api-loader-map/dist'>js-api-loader-map</a></li>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": [
3+
"plugin:@typescript-eslint/recommended"
4+
],
5+
"parser": "@typescript-eslint/parser",
6+
"rules": {
7+
"@typescript-eslint/ban-ts-comment": 0,
8+
"@typescript-eslint/no-this-alias": 1,
9+
"@typescript-eslint/no-empty-function": 1,
10+
"@typescript-eslint/explicit-module-boundary-types": 1,
11+
"@typescript-eslint/no-unused-vars": 1
12+
}
13+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Google Maps JavaScript Sample
2+
3+
## event-poi
4+
5+
This example demonstrates the use of click event listeners on POIs (points of interest).
6+
7+
## Setup
8+
9+
### Before starting run:
10+
11+
`npm i`
12+
13+
### Run an example on a local web server
14+
15+
`cd samples/event-poi`
16+
`npm start`
17+
18+
### Build an individual example
19+
20+
`cd samples/event-poi`
21+
`npm run build`
22+
23+
From 'samples':
24+
25+
`npm run build --workspace=event-poi/`
26+
27+
### Build all of the examples.
28+
29+
From 'samples':
30+
31+
`npm run build-all`
32+
33+
### Run lint to check for problems
34+
35+
`cd samples/event-poi`
36+
`npx eslint index.ts`
37+
38+
## Feedback
39+
40+
For feedback related to this sample, please open a new issue on
41+
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!doctype html>
2+
<!--
3+
@license
4+
Copyright 2026 Google LLC. All Rights Reserved.
5+
SPDX-License-Identifier: Apache-2.0
6+
-->
7+
<!-- [START maps_event_poi] -->
8+
<html>
9+
<head>
10+
<title>POI Click Events</title>
11+
12+
<link rel="stylesheet" type="text/css" href="./style.css" />
13+
<script type="module" src="./index.js"></script>
14+
<!-- prettier-ignore -->
15+
<script>(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})
16+
({key: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8", v: "weekly"});</script>
17+
</head>
18+
<body>
19+
<gmp-map center="-33.871, 151.197" zoom="18">
20+
</gmp-map>
21+
</body>
22+
</html>
23+
<!-- [END maps_event_poi] -->
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// [START maps_event_poi]
8+
let innerMap;
9+
10+
async function initMap() {
11+
// Request the needed libraries.
12+
await google.maps.importLibrary('maps');
13+
14+
// Retrieve the map element.
15+
const mapElement = document.querySelector(
16+
'gmp-map'
17+
) as google.maps.MapElement;
18+
19+
// Get the inner map from the map element.
20+
innerMap = mapElement.innerMap;
21+
22+
// Create the initial info window.
23+
let infowindow = new google.maps.InfoWindow({});
24+
25+
// Add a listener for click events on the map.
26+
innerMap.addListener('click', (event) => {
27+
// Prevent the default POI info window from showing.
28+
event.stop();
29+
30+
// If the event has a placeId, show the info window.
31+
if (isIconMouseEvent(event) && event.placeId) {
32+
showInfoWindow(event, infowindow);
33+
} else {
34+
// Close the info window if there is no placeId.
35+
infowindow.close();
36+
}
37+
});
38+
}
39+
40+
// Helper function to show the info window.
41+
async function showInfoWindow(event: google.maps.IconMouseEvent, infowindow: google.maps.InfoWindow) {
42+
// Retrieve the place details for the selected POI.
43+
const place = await getPlaceDetails(event.placeId);
44+
45+
// Assemble the info window content.
46+
const content = document.createElement('div');
47+
const address = document.createElement('div');
48+
const placeId = document.createElement('div');
49+
address.textContent = place.formattedAddress || '';
50+
placeId.textContent = place.id || '';
51+
content.append(address, placeId);
52+
53+
// Create an element to use the place name as header content.
54+
const name = document.createElement('div');
55+
name.style.fontWeight = 'bold';
56+
name.style.fontSize = 'medium';
57+
name.textContent = place.displayName || '';
58+
59+
// Update info window options.
60+
infowindow.setOptions({
61+
position: event.latLng,
62+
pixelOffset: new google.maps.Size(0, -30),
63+
headerContent: name,
64+
content: content,
65+
});
66+
67+
innerMap.panTo(event.latLng);
68+
infowindow.open(innerMap);
69+
}
70+
71+
// Helper function to get place details.
72+
async function getPlaceDetails(placeId) {
73+
// Import the Places library.
74+
const { Place } = (await google.maps.importLibrary(
75+
'places'
76+
)) as google.maps.PlacesLibrary;
77+
78+
// Create a Place instance with the place id and fetch the details.
79+
const place = new Place({ id: placeId });
80+
await place.fetchFields({
81+
fields: ['displayName', 'formattedAddress'],
82+
});
83+
84+
// Return the place details.
85+
return place;
86+
}
87+
88+
// Helper type guard to determine if the event is an IconMouseEvent.
89+
function isIconMouseEvent(
90+
e: google.maps.MapMouseEvent | google.maps.IconMouseEvent
91+
): e is google.maps.IconMouseEvent {
92+
return 'placeId' in e;
93+
}
94+
95+
initMap();
96+
// [END maps_event_poi]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@js-api-samples/event-poi",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"build": "tsc && bash ../jsfiddle.sh event-poi && bash ../app.sh event-poi && bash ../docs.sh event-poi && npm run build:vite --workspace=. && bash ../dist.sh event-poi",
6+
"test": "tsc && npm run build:vite --workspace=.",
7+
"start": "tsc && vite build --base './' && vite",
8+
"build:vite": "vite build --base './'",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
13+
}
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @license
3+
* Copyright 2026 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/* [START maps_event_poi] */
7+
8+
/* Optional: Makes the sample page fill the window. */
9+
html,
10+
body {
11+
height: 100%;
12+
margin: 0;
13+
padding: 0;
14+
}
15+
16+
.title {
17+
font-weight: bold;
18+
}
19+
20+
/* [END maps_event_poi] */
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"module": "esnext",
4+
"target": "esnext",
5+
"strict": true,
6+
"noImplicitAny": false,
7+
"lib": [
8+
"es2015",
9+
"esnext",
10+
"es6",
11+
"dom",
12+
"dom.iterable"
13+
],
14+
"moduleResolution": "Node",
15+
"jsx": "preserve"
16+
}
17+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
html,body{height:100%;margin:0;padding:0}.title{font-weight:700}

dist/samples/event-poi/dist/assets/index-Cu_45cVy.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)