Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7902536
feat(samples): add advanced place details and search samples
ejhaselden Aug 27, 2026
405e849
fix(samples): add v=alpha to preview advanced place UI elements
ejhaselden Aug 27, 2026
21b6e40
fix(samples): change v=alpha to v=beta for advanced place elements
ejhaselden Aug 27, 2026
c9c9141
fix(samples): explicitly list gmp-place-name so Place titles render i…
ejhaselden Aug 27, 2026
ecce897
Merge branch 'main' into add-advanced-place-elements
ejhaselden Aug 27, 2026
e3d008d
feat(samples): deliberately omit gmp-place-name in advanced place det…
ejhaselden Aug 27, 2026
274d8fa
Merge origin/add-advanced-place-elements
ejhaselden Aug 27, 2026
a7a2639
style(samples): format ui-kit-place-details-demo files to satisfy pre…
ejhaselden Aug 27, 2026
980161f
chore(samples): remove mistakenly committed ui-kit-place-details-demo
ejhaselden Aug 27, 2026
84a2285
feat(samples): add advanced place list demo
ejhaselden Aug 27, 2026
1926a5c
fix(samples): import places API explicitly in advanced place list
ejhaselden Aug 27, 2026
eeeb916
fix(samples): substitute missing dummy PRNs with known valid Place ID…
ejhaselden Aug 27, 2026
23c0d2b
fix(samples): change comma-separated places list to space-separated a…
ejhaselden Aug 27, 2026
246c006
fix(samples): populate Advanced Place List demo with top 5 global lan…
ejhaselden Aug 27, 2026
1541ebf
chore: enforce strict typescript types; minor fixes.
willum070 Aug 27, 2026
ed9a932
chore: one last prettification
willum070 Aug 27, 2026
e9aeef0
fix(samples): Add <gmp-place-name> to advanced samples as requested
ejhaselden Aug 27, 2026
f546796
fix(samples): omit <gmp-place-name> on advanced place search nearby d…
ejhaselden Aug 27, 2026
0db32b5
Merge branch 'main' into add-advanced-place-elements
ejhaselden Aug 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions samples/ui-kit-advanced-place-details-compact/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Google Maps JavaScript Sample

## ui-kit-advanced-place-details-compact

The ui-kit-advanced-place-details-compact sample demonstrates how to use the UI Kit for Place Details in a compact layout.

Follow these instructions to set up and run ui-kit-advanced-place-details-compact sample on your local computer.

## Setup

### Before starting run:

`$npm i`

### Run an example on a local web server

First `cd` to the folder for the sample to run, then:

`$npm start`

### Build an individual example

From `samples/`:

`$npm run build --workspace=ui-kit-advanced-place-details-compact/`

### Build all of the examples.

From `samples/`:
`$npm run build-all`

## Feedback

For feedback related to this sample, please open a new issue on
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
66 changes: 66 additions & 0 deletions samples/ui-kit-advanced-place-details-compact/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!--
@license
Copyright 2026 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!--[START maps_ui_kit_advanced_place_details_compact] -->
<!doctype html>
<html>
<head>
<title>Place Details Compact with Google Maps</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="module" src="./index.js"></script>
<script>
// prettier-ignore
(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))})({
key: "GOOGLE_MAPS_API_KEY",
v: "beta"
});
</script>
</head>
<body>
<div class="container">
<!-- map-id is required to use Advanced Markers. See https://developers.google.com/maps/documentation/javascript/map-ids/mapid-over. -->
<gmp-map zoom="17" map-id="DEMO_MAP_ID">
<gmp-advanced-marker></gmp-advanced-marker>
</gmp-map>
</div>
<!--
The gmp-advanced-place-details-compact element is styled inline because it is
conditionally rendered and moved into the info window, which is
part of the map's shadow DOM.
-->
<!--[START maps_ui_kit_advanced_place_details_compact_map_setup] -->
<gmp-advanced-place-details-compact
orientation="horizontal"
truncation-preferred
style="
width: 400px;
padding: 0;
margin: 0;
border: none;
background-color: transparent;
color-scheme: light;
">
<gmp-place-details-place-request
place="places/ChIJC8HakaIRkFQRiOgkgdHmqkk"></gmp-place-details-place-request>
<!--[END maps_ui_kit_advanced_place_details_compact_map_setup] -->
<!--[START maps_ui_kit_advanced_place_details_compact_config] -->

Comment thread
ejhaselden marked this conversation as resolved.
<gmp-place-name></gmp-place-name>
<gmp-place-media lightbox-preferred></gmp-place-media>
Comment thread
ejhaselden marked this conversation as resolved.
<gmp-place-rating></gmp-place-rating>
<gmp-place-type></gmp-place-type>
<gmp-place-price></gmp-place-price>
<gmp-place-accessible-entrance-icon></gmp-place-accessible-entrance-icon>
<gmp-place-open-now-status></gmp-place-open-now-status>
<gmp-place-attribution
light-scheme-color="gray"
dark-scheme-color="white"></gmp-place-attribution>

<!--[END maps_ui_kit_advanced_place_details_compact_config] -->
</gmp-advanced-place-details-compact>
</body>
</html>
<!--[END maps_ui_kit_advanced_place_details_compact] -->
84 changes: 84 additions & 0 deletions samples/ui-kit-advanced-place-details-compact/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* @license
* Copyright 2025 Google LLC. All Rights Reserved.
Comment thread
ejhaselden marked this conversation as resolved.
* SPDX-License-Identifier: Apache-2.0
*/
/* [START maps_ui_kit_advanced_place_details_compact] */
// Use querySelector to select elements for interaction.
/* [START maps_ui_kit_advanced_place_details_compact_query_selector] */
const map = document.querySelector<google.maps.MapElement>('gmp-map')!;
const placeDetails = document.querySelector<
HTMLElement & { place?: google.maps.places.Place }
>('gmp-advanced-place-details-compact')!;
const placeDetailsRequest = document.querySelector<HTMLElement>(
'gmp-place-details-place-request'
)!;
const marker = document.querySelector<google.maps.marker.AdvancedMarkerElement>(
'gmp-advanced-marker'
)!;
/* [END maps_ui_kit_advanced_place_details_compact_query_selector] */
async function init(): Promise<void> {
// Request needed libraries.
void Promise.all([
google.maps.importLibrary('marker'),
google.maps.importLibrary('places'),
]);
const { InfoWindow } = await google.maps.importLibrary('maps');

await window.customElements.whenDefined('gmp-map');
// Set the inner map options.
map.innerMap.setOptions({
mapTypeControl: false,
streetViewControl: false,
});

await window.customElements.whenDefined('gmp-advanced-marker');
marker.collisionBehavior = 'REQUIRED_AND_HIDES_OPTIONAL';

const infoWindow = new InfoWindow();
infoWindow.addListener('close', () => {
marker.position = null;
});

const showInfoWindow = () => {
if (infoWindow.isOpen) return;
infoWindow.setContent(placeDetails);
infoWindow.open({ anchor: marker });
};

placeDetails.addEventListener('gmp-load', () => {
// For the initial load case, with no user click, we fall back to the place's location, and ensure the map has a center set and the InfoWindow is show.
// (The clicked POI LatLng will be a more natural marker position, when available.)
if (!map.center && placeDetails.place?.location) {
map.center = marker.position = placeDetails.place.location;
showInfoWindow();
}
});

/* [START maps_ui_kit_advanced_place_details_compact_event] */
// Add an event listener to handle clicks.
map.innerMap.addListener(
'click',
(event: google.maps.MapMouseEvent | google.maps.IconMouseEvent) => {
event.stop();

if ('placeId' in event && event.placeId) {
// When the user clicks a POI.
marker.position = event.latLng;
placeDetailsRequest.setAttribute(
'place',
`places/${event.placeId}`
);
showInfoWindow();
} else {
// When the user clicks the map (not on a POI).
marker.position = null;
placeDetailsRequest.removeAttribute('place');
console.log('No place was selected.');
}
}
);
}
/* [END maps_ui_kit_advanced_place_details_compact_event] */
void init();
/* [END maps_ui_kit_advanced_place_details_compact] */
12 changes: 12 additions & 0 deletions samples/ui-kit-advanced-place-details-compact/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@js-api-samples/ui-kit-advanced-place-details-compact",
"version": "1.0.0",
"scripts": {
"build": "bash ../build-single.sh",
"test": "tsc && npm run build:vite --workspace=.",
"start": "tsc && vite build --config ../../vite.config.js --base './' && vite --config ../../vite.config.js",
"build:vite": "vite build --config ../../vite.config.js --base './'",
"preview": "vite preview --config ../../vite.config.js"
},
"author": "Google LLC"
}
26 changes: 26 additions & 0 deletions samples/ui-kit-advanced-place-details-compact/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* @license
* Copyright 2026 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/
/* [START maps_ui_kit_place_details_compact] */
/*
* Optional: Makes the sample page fill the window.
*/
html,
body {
height: 100%;
margin: 0;
padding: 0;
}

.container {
display: flex;
height: 100vh;
width: 100%;
}

gmp-map {
flex-grow: 1;
}
/* [END maps_ui_kit_place_details_compact] */
7 changes: 7 additions & 0 deletions samples/ui-kit-advanced-place-details-compact/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "."
},
"include": ["./*.ts"]
}
35 changes: 35 additions & 0 deletions samples/ui-kit-advanced-place-details/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Google Maps JavaScript Sample

## ui-kit-advanced-place-details

The ui-kit-advanced-place-details sample demonstrates how to use the UI Kit Place Details element.

Follow these instructions to set up and run ui-kit-advanced-place-details sample on your local computer.

## Setup

### Before starting run:

`$npm i`

### Run an example on a local web server

First `cd` to the folder for the sample to run, then:

`$npm start`

### Build an individual example

From `samples/`:

`$npm run build --workspace=ui-kit-advanced-place-details/`

### Build all of the examples.

From `samples/`:
`$npm run build-all`

## Feedback

For feedback related to this sample, please open a new issue on
[GitHub](https://github.com/googlemaps-samples/js-api-samples/issues).
54 changes: 54 additions & 0 deletions samples/ui-kit-advanced-place-details/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!--
@license
Copyright 2026 Google LLC. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
-->
<!--[START maps_ui_kit_advanced_place_details] -->
<!doctype html>
<html>
<head>
<title>Place Details with Google Maps</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="module" src="./index.js"></script>
<script>
// prettier-ignore
(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))})({
key: "GOOGLE_MAPS_API_KEY",
v: "beta"
});
</script>
</head>
<body>
<!--[START maps_ui_kit_advanced_place_details_map] -->
<div class="container">
<!-- map-id is required to use advanced markers. See https://developers.google.com/maps/documentation/javascript/map-ids/mapid-over. -->
<gmp-map zoom="17" map-id="DEMO_MAP_ID">
<gmp-advanced-marker></gmp-advanced-marker>
</gmp-map>
<div class="ui-panel">
<gmp-advanced-place-details>
<gmp-place-details-place-request
place="places/ChIJC8HakaIRkFQRiOgkgdHmqkk"></gmp-place-details-place-request>

Comment thread
ejhaselden marked this conversation as resolved.
<gmp-place-name></gmp-place-name>
<gmp-place-address></gmp-place-address>
<gmp-place-rating></gmp-place-rating>
<gmp-place-type></gmp-place-type>
<gmp-place-price></gmp-place-price>
<gmp-place-accessible-entrance-icon></gmp-place-accessible-entrance-icon>
<gmp-place-opening-hours></gmp-place-opening-hours>
<gmp-place-website></gmp-place-website>
<gmp-place-phone-number></gmp-place-phone-number>
<gmp-place-summary></gmp-place-summary>
<gmp-place-type-specific-highlights></gmp-place-type-specific-highlights>
<gmp-place-review-summary></gmp-place-review-summary>
<gmp-place-reviews></gmp-place-reviews>
<gmp-place-feature-list></gmp-place-feature-list>
</gmp-advanced-place-details>
</div>
</div>
<!--[END maps_ui_kit_advanced_place_details_map] -->
</body>
</html>
<!--[END maps_ui_kit_advanced_place_details] -->
Loading