Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ <h1>Maps JSAPI Samples</h1>
<li><a href='/samples/routes-route-matrix/dist'>routes-route-matrix</a></li>
<li><a href='/samples/streetview-overlays/dist'>streetview-overlays</a></li>
<li><a href='/samples/test-example/dist'>test-example</a></li>
<li><a href='/samples/ui-kit-advanced-place-details/dist'>ui-kit-advanced-place-details</a></li>
<li><a href='/samples/ui-kit-advanced-place-details-compact/dist'>ui-kit-advanced-place-details-compact</a></li>
<li><a href='/samples/ui-kit-advanced-place-list/dist'>ui-kit-advanced-place-list</a></li>
<li><a href='/samples/ui-kit-advanced-place-search-nearby/dist'>ui-kit-advanced-place-search-nearby</a></li>
<li><a href='/samples/ui-kit-advanced-place-search-text/dist'>ui-kit-advanced-place-search-text</a></li>
<li><a href='/samples/ui-kit-place-details/dist'>ui-kit-place-details</a></li>
<li><a href='/samples/ui-kit-place-details-compact/dist'>ui-kit-place-details-compact</a></li>
<li><a href='/samples/ui-kit-place-search-nearby/dist'>ui-kit-place-search-nearby</a></li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": [
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"rules": {
"@typescript-eslint/ban-ts-comment": 0,
"@typescript-eslint/no-this-alias": 1,
"@typescript-eslint/no-empty-function": 1,
"@typescript-eslint/explicit-module-boundary-types": 1,
"@typescript-eslint/no-unused-vars": 1
}
}
35 changes: 35 additions & 0 deletions dist/samples/ui-kit-advanced-place-details-compact/app/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 dist/samples/ui-kit-advanced-place-details-compact/app/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] -->

<gmp-place-name></gmp-place-name>
<gmp-place-media lightbox-preferred></gmp-place-media>
<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 dist/samples/ui-kit-advanced-place-details-compact/app/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* @license
* Copyright 2025 Google LLC. All Rights Reserved.
* 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] */
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 dist/samples/ui-kit-advanced-place-details-compact/app/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] */
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "."
},
"include": ["./*.ts"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
html,body{height:100%;margin:0;padding:0}.container{width:100%;height:100vh;display:flex}gmp-map{flex-grow:1}

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

66 changes: 66 additions & 0 deletions dist/samples/ui-kit-advanced-place-details-compact/dist/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" />
<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: "AIzaSyA6myHzS10YXdcazAFalmXvDkrYCp5cLc8",
v: "beta"
});
</script>
<script type="module" crossorigin src="./assets/index-CupoL2UV.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-CEzprmY2.css">
</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] -->

<gmp-place-name></gmp-place-name>
<gmp-place-media lightbox-preferred></gmp-place-media>
<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] -->
Loading