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
8 changes: 4 additions & 4 deletions dist/samples/ui-kit-place-details/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
</head>
<body>
<!--[START maps_ui_kit_place_details_map] -->
<gmp-map center="-37.813,144.963" zoom="2" map-id="DEMO_MAP_ID">
<gmp-place-details
size="x-large"
slot="control-inline-start-block-start"></gmp-place-details>
<gmp-map center="47.759737, -122.250632" zoom="16" map-id="DEMO_MAP_ID">
<div class="widget-container" slot="control-inline-start-block-start">
<gmp-place-details size="x-large"></gmp-place-details>
</div>
<gmp-advanced-marker></gmp-advanced-marker>
</gmp-map>
<!--[END maps_ui_kit_place_details_map] -->
Expand Down
58 changes: 28 additions & 30 deletions dist/samples/ui-kit-place-details/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,58 @@ const placeDetails = document.querySelector('gmp-place-details') as any;
const marker = document.querySelector('gmp-advanced-marker') as any;
/* [END maps_ui_kit_place_details_query_selector] */

async function initMap(): Promise<void> {
// Request needed libraries.
const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
const { Place } = await google.maps.importLibrary("places") as google.maps.PlacesLibrary;
let center = { lat: 47.759737, lng: -122.250632 };

// Calls the geolocation helper function to center the map on the current
// device location.
findCurrentLocation();
async function initMap(): Promise<void> {
// Request needed libraries.
const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
const { Place } = await google.maps.importLibrary("places") as google.maps.PlacesLibrary;

// Hide the map type control.
map.innerMap.setOptions({mapTypeControl: false});

// Set the default selection.
const place = new Place({
id: "ChIJC8HakaIRkFQRiOgkgdHmqkk",
requestedLanguage: "en", // optional
});
await placeDetails.configureFromPlace(place);
let adjustedCenter = offsetLatLngRight(placeDetails.place.location, -0.005);
map.innerMap.panTo(adjustedCenter);
map.innerMap.setZoom(16);

marker.position = placeDetails.place.location;
marker.style.display = 'block';

/* [START maps_ui_kit_place_details_event] */
// Add an event listener to handle map clicks.
map.innerMap.addListener('click', async (event) => {
marker.position = null;
event.stop();
placeDetails.style.visibility = 'visible';
if (event.placeId) {
// Fire when the user clicks a POI.
await placeDetails.configureFromPlace({id: event.placeId});
} else {
// Fire when the user clicks the map (not on a POI).
await placeDetails.configureFromLocation(event.latLng);
}
// Get the offset center.
let adjustedCenter = offsetLatLngRight(placeDetails.place.location, -0.005);

// Show the marker at the selected place.
marker.position = placeDetails.place.location;
marker.style.display = 'block';
map.innerMap.panTo(adjustedCenter);
});
}
/* [END maps_ui_kit_place_details_event] */

// Helper function for geolocation.
async function findCurrentLocation() {
const { LatLng } = await google.maps.importLibrary('core') as google.maps.CoreLibrary;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
const pos =
new LatLng(position.coords.latitude, position.coords.longitude);
map.innerMap.panTo(pos);
map.innerMap.setZoom(16);
},
() => {
console.log('The Geolocation service failed.');
map.innerMap.setZoom(16);
},
);
} else {
console.log('Your browser doesn\'t support geolocation');
map.innerMap.setZoom(16);
}
// Helper function to offset the map center.
function offsetLatLngRight(latLng, longitudeOffset) {
const newLng = latLng.lng() + longitudeOffset;
return new google.maps.LatLng(latLng.lat(), newLng);
}
/* [END maps_ui_kit_place_details_event] */

declare global {
interface Window {
Expand Down
14 changes: 12 additions & 2 deletions dist/samples/ui-kit-place-details/app/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ body {
height: 100%;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
display: block;
}

h1 {
Expand All @@ -20,18 +21,27 @@ h1 {
}

gmp-map {
height: 800px;
height: 400px;
}

gmp-place-details {
visibility: hidden;
background-color: #fff;
border-radius: 8px;
margin: 20px;
width: 400px;
padding: 12px;
margin-top: 10px;
overflow-y: auto;
}

gmp-advanced-marker {
display: none;
}

.widget-container {
height: 400px;
width: 457px;
overflow-y: auto;
overflow-x: hidden;
}
/* [END maps_ui_kit_place_details] */

This file was deleted.

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* @license
* Copyright 2025 Google LLC. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/html,body{height:100%;margin:0;font-family:Arial,Helvetica,sans-serif;display:block}h1{font-size:16px;text-align:center}gmp-map{height:400px}gmp-place-details{background-color:#fff;border-radius:8px;margin:10px 20px 20px;width:400px;padding:12px;overflow-y:auto}gmp-advanced-marker{display:none}.widget-container{height:400px;width:457px;overflow-y:auto;overflow-x:hidden}

This file was deleted.

12 changes: 6 additions & 6 deletions dist/samples/ui-kit-place-details/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<head>
<title>Click on the map to view place details</title>
<meta charset="utf-8">
<script type="module" crossorigin src="./assets/index-B8_Ypk3a.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-f2zskmln.css">
<script type="module" crossorigin src="./assets/index-CadsbSRj.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-DAWyXXsz.css">
</head>
<body>
<!--[START maps_ui_kit_place_details_map] -->
<gmp-map center="-37.813,144.963" zoom="2" map-id="DEMO_MAP_ID">
<gmp-place-details
size="x-large"
slot="control-inline-start-block-start"></gmp-place-details>
<gmp-map center="47.759737, -122.250632" zoom="16" map-id="DEMO_MAP_ID">
<div class="widget-container" slot="control-inline-start-block-start">
<gmp-place-details size="x-large"></gmp-place-details>
</div>
<gmp-advanced-marker></gmp-advanced-marker>
</gmp-map>
<!--[END maps_ui_kit_place_details_map] -->
Expand Down
8 changes: 4 additions & 4 deletions dist/samples/ui-kit-place-details/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
</head>
<body>
<!--[START maps_ui_kit_place_details_map] -->
<gmp-map center="-37.813,144.963" zoom="2" map-id="DEMO_MAP_ID">
<gmp-place-details
size="x-large"
slot="control-inline-start-block-start"></gmp-place-details>
<gmp-map center="47.759737, -122.250632" zoom="16" map-id="DEMO_MAP_ID">
<div class="widget-container" slot="control-inline-start-block-start">
<gmp-place-details size="x-large"></gmp-place-details>
</div>
<gmp-advanced-marker></gmp-advanced-marker>
</gmp-map>
<!--[END maps_ui_kit_place_details_map] -->
Expand Down
43 changes: 20 additions & 23 deletions dist/samples/ui-kit-place-details/docs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,30 @@ const map = document.querySelector('gmp-map');
const placeDetails = document.querySelector('gmp-place-details');
const marker = document.querySelector('gmp-advanced-marker');
/* [END maps_ui_kit_place_details_query_selector] */
let center = { lat: 47.759737, lng: -122.250632 };
async function initMap() {
// Request needed libraries.
const { Map } = await google.maps.importLibrary("maps");
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");
const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary("marker");
const { Place } = await google.maps.importLibrary("places");
// Calls the geolocation helper function to center the map on the current
// device location.
findCurrentLocation();
// Hide the map type control.
map.innerMap.setOptions({ mapTypeControl: false });
// Set the default selection.
const place = new Place({
id: "ChIJC8HakaIRkFQRiOgkgdHmqkk",
requestedLanguage: "en", // optional
});
await placeDetails.configureFromPlace(place);
let adjustedCenter = offsetLatLngRight(placeDetails.place.location, -0.005);
map.innerMap.panTo(adjustedCenter);
map.innerMap.setZoom(16);
marker.position = placeDetails.place.location;
marker.style.display = 'block';
/* [START maps_ui_kit_place_details_event] */
// Add an event listener to handle map clicks.
map.innerMap.addListener('click', async (event) => {
marker.position = null;
event.stop();
placeDetails.style.visibility = 'visible';
if (event.placeId) {
// Fire when the user clicks a POI.
await placeDetails.configureFromPlace({ id: event.placeId });
Expand All @@ -34,29 +42,18 @@ async function initMap() {
// Fire when the user clicks the map (not on a POI).
await placeDetails.configureFromLocation(event.latLng);
}
// Get the offset center.
let adjustedCenter = offsetLatLngRight(placeDetails.place.location, -0.005);
// Show the marker at the selected place.
marker.position = placeDetails.place.location;
marker.style.display = 'block';
map.innerMap.panTo(adjustedCenter);
});
}
/* [END maps_ui_kit_place_details_event] */
// Helper function for geolocation.
async function findCurrentLocation() {
const { LatLng } = await google.maps.importLibrary('core');
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition((position) => {
const pos = new LatLng(position.coords.latitude, position.coords.longitude);
map.innerMap.panTo(pos);
map.innerMap.setZoom(16);
}, () => {
console.log('The Geolocation service failed.');
map.innerMap.setZoom(16);
});
}
else {
console.log('Your browser doesn\'t support geolocation');
map.innerMap.setZoom(16);
}
// Helper function to offset the map center.
function offsetLatLngRight(latLng, longitudeOffset) {
const newLng = latLng.lng() + longitudeOffset;
return new google.maps.LatLng(latLng.lat(), newLng);
}
window.initMap = initMap;
export {};
58 changes: 28 additions & 30 deletions dist/samples/ui-kit-place-details/docs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,60 +11,58 @@ const placeDetails = document.querySelector('gmp-place-details') as any;
const marker = document.querySelector('gmp-advanced-marker') as any;
/* [END maps_ui_kit_place_details_query_selector] */

async function initMap(): Promise<void> {
// Request needed libraries.
const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
const { Place } = await google.maps.importLibrary("places") as google.maps.PlacesLibrary;
let center = { lat: 47.759737, lng: -122.250632 };

// Calls the geolocation helper function to center the map on the current
// device location.
findCurrentLocation();
async function initMap(): Promise<void> {
// Request needed libraries.
const { Map } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
const { AdvancedMarkerElement, PinElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
const { Place } = await google.maps.importLibrary("places") as google.maps.PlacesLibrary;

// Hide the map type control.
map.innerMap.setOptions({mapTypeControl: false});

// Set the default selection.
const place = new Place({
id: "ChIJC8HakaIRkFQRiOgkgdHmqkk",
requestedLanguage: "en", // optional
});
await placeDetails.configureFromPlace(place);
let adjustedCenter = offsetLatLngRight(placeDetails.place.location, -0.005);
map.innerMap.panTo(adjustedCenter);
map.innerMap.setZoom(16);

marker.position = placeDetails.place.location;
marker.style.display = 'block';

/* [START maps_ui_kit_place_details_event] */
// Add an event listener to handle map clicks.
map.innerMap.addListener('click', async (event) => {
marker.position = null;
event.stop();
placeDetails.style.visibility = 'visible';
if (event.placeId) {
// Fire when the user clicks a POI.
await placeDetails.configureFromPlace({id: event.placeId});
} else {
// Fire when the user clicks the map (not on a POI).
await placeDetails.configureFromLocation(event.latLng);
}
// Get the offset center.
let adjustedCenter = offsetLatLngRight(placeDetails.place.location, -0.005);

// Show the marker at the selected place.
marker.position = placeDetails.place.location;
marker.style.display = 'block';
map.innerMap.panTo(adjustedCenter);
});
}
/* [END maps_ui_kit_place_details_event] */

// Helper function for geolocation.
async function findCurrentLocation() {
const { LatLng } = await google.maps.importLibrary('core') as google.maps.CoreLibrary;
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
const pos =
new LatLng(position.coords.latitude, position.coords.longitude);
map.innerMap.panTo(pos);
map.innerMap.setZoom(16);
},
() => {
console.log('The Geolocation service failed.');
map.innerMap.setZoom(16);
},
);
} else {
console.log('Your browser doesn\'t support geolocation');
map.innerMap.setZoom(16);
}
// Helper function to offset the map center.
function offsetLatLngRight(latLng, longitudeOffset) {
const newLng = latLng.lng() + longitudeOffset;
return new google.maps.LatLng(latLng.lat(), newLng);
}
/* [END maps_ui_kit_place_details_event] */

declare global {
interface Window {
Expand Down
Loading