Skip to content

Commit 998519a

Browse files
Update dist folder [skip ci] (#1008)
1 parent 3a1c228 commit 998519a

39 files changed

+2640
-0
lines changed

dist/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ <h1>Maps JSAPI Samples</h1>
4848
<li><a href='/samples/advanced-markers-html-simple/dist'>advanced-markers-html-simple</a></li>
4949
<li><a href='/samples/advanced-markers-simple/dist'>advanced-markers-simple</a></li>
5050
<li><a href='/samples/advanced-markers-zoom/dist'>advanced-markers-zoom</a></li>
51+
<li><a href='/samples/ai-powered-summaries/dist'>ai-powered-summaries</a></li>
52+
<li><a href='/samples/ai-powered-summaries-basic/dist'>ai-powered-summaries-basic</a></li>
5153
<li><a href='/samples/boundaries-choropleth/dist'>boundaries-choropleth</a></li>
5254
<li><a href='/samples/boundaries-click/dist'>boundaries-click</a></li>
5355
<li><a href='/samples/boundaries-simple/dist'>boundaries-simple</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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Google Maps JavaScript Sample
2+
3+
## ai-powered-summaries-basic
4+
5+
The ai-powered-summaries-basic sample demonstrates how to retrieve AI-powered summaries.
6+
7+
Follow these instructions to set up and run ai-powered-summaries-basic sample on your local computer.
8+
9+
## Setup
10+
11+
### Before starting run:
12+
13+
`npm i`
14+
15+
### Run an example on a local web server
16+
17+
First `cd` to the folder for the sample to run, then:
18+
19+
`npm start`
20+
21+
### Build an individual example
22+
23+
From `samples/`:
24+
25+
`npm run build --workspace=ai-powered-summaries-basic/`
26+
27+
### Build all of the examples.
28+
29+
From `samples/`:
30+
31+
`npm run build-all`
32+
33+
## Feedback
34+
35+
For feedback related to this sample, please open a new issue on
36+
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<!--
3+
@license
4+
Copyright 2025 Google LLC. All Rights Reserved.
5+
SPDX-License-Identifier: Apache-2.0
6+
-->
7+
<!-- [START maps_ai_powered_summaries_basic] -->
8+
<html>
9+
<head>
10+
<title>AI-powered Summaries Basic Sample</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
20+
center="32.7360353,-117.1509849"
21+
zoom="14"
22+
map-id="DEMO_MAP_ID">
23+
</gmp-map>
24+
</body>
25+
</html>
26+
<!-- [END maps_ai_powered_summaries_basic] -->
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// [START maps_ai_powered_summaries_basic]
8+
const mapElement = document.querySelector('gmp-map') as google.maps.MapElement;
9+
let innerMap;
10+
let infoWindow;
11+
12+
async function initMap() {
13+
const { Map, InfoWindow } = (await google.maps.importLibrary(
14+
'maps'
15+
)) as google.maps.MapsLibrary;
16+
17+
innerMap = mapElement.innerMap;
18+
innerMap.setOptions({
19+
mapTypeControl: false
20+
});
21+
22+
infoWindow = new InfoWindow();
23+
getPlaceDetails();
24+
}
25+
26+
async function getPlaceDetails() {
27+
// Request needed libraries.
28+
const [ {AdvancedMarkerElement}, { Place } ] = await Promise.all([
29+
google.maps.importLibrary('marker') as Promise<google.maps.MarkerLibrary>,
30+
google.maps.importLibrary('places') as Promise<google.maps.PlacesLibrary>,
31+
]);
32+
33+
// [START maps_ai_powered_summaries_basic_placeid]
34+
// Use place ID to create a new Place instance.
35+
const place = new Place({
36+
id: 'ChIJzzc-aWUM3IARPOQr9sA6vfY', // San Diego Botanic Garden
37+
});
38+
// [END maps_ai_powered_summaries_basic_placeid]
39+
40+
// Call fetchFields, passing the needed data fields.
41+
// [START maps_ai_powered_summaries_basic_fetchfields]
42+
await place.fetchFields({
43+
fields: [
44+
'displayName',
45+
'formattedAddress',
46+
'location',
47+
'generativeSummary',
48+
],
49+
});
50+
// [END maps_ai_powered_summaries_basic_fetchfields]
51+
52+
// Add an Advanced Marker
53+
const marker = new AdvancedMarkerElement({
54+
map: innerMap,
55+
position: place.location,
56+
title: place.displayName,
57+
});
58+
59+
// Create a content container.
60+
const content = document.createElement('div');
61+
// Populate the container with data.
62+
const address = document.createElement('div');
63+
const summary = document.createElement('div');
64+
const lineBreak = document.createElement('br');
65+
const attribution = document.createElement('div');
66+
67+
// Retrieve the textual data (summary, disclosure, flag URI).
68+
//@ts-ignore
69+
let overviewText = place.generativeSummary.overview ?? 'No summary is available.';
70+
//@ts-ignore
71+
let disclosureText = place.generativeSummary.disclosureText;
72+
//@ts-ignore
73+
let reportingUri = place.generativeSummary.flagContentURI;
74+
75+
// Create HTML for reporting link.
76+
const reportingLink = document.createElement('a');
77+
reportingLink.href = reportingUri;
78+
reportingLink.target = '_blank';
79+
reportingLink.textContent = "Report a problem."
80+
81+
// Add text to layout.
82+
address.textContent = place.formattedAddress ?? '';
83+
summary.textContent = overviewText;
84+
attribution.textContent = `${disclosureText} `;
85+
attribution.appendChild(reportingLink);
86+
87+
content.append(address, lineBreak, summary, lineBreak, attribution);
88+
89+
innerMap.setCenter(place.location);
90+
91+
// Handle marker click.
92+
marker.addListener('gmp-click', () => {
93+
showInfoWindow(marker, place, content);
94+
});
95+
96+
// Display the info window at load time.
97+
showInfoWindow(marker, place, content);
98+
}
99+
100+
function showInfoWindow(marker, place, content) {
101+
// Display an info window.
102+
infoWindow.setHeaderContent(place.displayName);
103+
infoWindow.setContent(content);
104+
infoWindow.open({
105+
anchor: marker,
106+
});
107+
}
108+
109+
initMap();
110+
// [END maps_ai_powered_summaries_basic]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@js-api-samples/ai-powered-summaries-basic",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"build": "tsc && bash ../jsfiddle.sh ai-powered-summaries-basic && bash ../app.sh ai-powered-summaries-basic && bash ../docs.sh ai-powered-summaries-basic && npm run build:vite --workspace=. && bash ../dist.sh ai-powered-summaries-basic",
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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC. All Rights Reserved.
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
/* [START maps_ai_powered_summaries_basic] */
7+
/*
8+
* Always set the map height explicitly to define the size of the div element
9+
* that contains the map.
10+
*/
11+
#map {
12+
height: 100%;
13+
}
14+
15+
/*
16+
* Optional: Makes the sample page fill the window.
17+
*/
18+
html,
19+
body {
20+
height: 100%;
21+
margin: 0;
22+
padding: 0;
23+
}
24+
25+
/* [END maps_ai_powered_summaries_basic] */
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+
}

dist/samples/ai-powered-summaries-basic/dist/assets/index-CFZ6i2WL.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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#map{height:100%}html,body{height:100%;margin:0;padding:0}

0 commit comments

Comments
 (0)