diff --git a/dist/samples/ui-kit-place-search/docs/index.js b/dist/samples/ui-kit-place-search/docs/index.js
index 68b73f6e..30b18ea3 100644
--- a/dist/samples/ui-kit-place-search/docs/index.js
+++ b/dist/samples/ui-kit-place-search/docs/index.js
@@ -12,16 +12,18 @@ const placeDetails = document.querySelector("gmp-place-details");
let marker = document.querySelector('gmp-advanced-marker');
/* [END maps_ui_kit_place_search_query_selectors] */
let markers = {};
-let infowindow;
+let infoWindow;
let mapCenter;
async function initMap() {
await google.maps.importLibrary("places");
const { InfoWindow } = await google.maps.importLibrary("maps");
const { spherical } = await google.maps.importLibrary("geometry");
- infowindow = new google.maps.InfoWindow;
+ infoWindow = new google.maps.InfoWindow;
function getContainingCircle(bounds) {
const diameter = spherical.computeDistanceBetween(bounds.getNorthEast(), bounds.getSouthWest());
- return { center: bounds.getCenter(), radius: diameter / 2 };
+ const calculatedRadius = diameter / 2;
+ const cappedRadius = Math.min(calculatedRadius, 50000); // Cap the radius to avoid an error.
+ return { center: bounds.getCenter(), radius: cappedRadius };
}
findCurrentLocation();
map.innerMap.setOptions({
@@ -32,7 +34,6 @@ async function initMap() {
typeSelect.addEventListener("change", (event) => {
// First remove all existing markers.
for (marker in markers) {
- console.log(marker);
markers[marker].map = null;
}
markers = {};
@@ -41,6 +42,7 @@ async function initMap() {
locationRestriction: getContainingCircle(map.innerMap.getBounds()),
includedPrimaryTypes: [typeSelect.value],
}).then(addMarkers);
+ // Handle user selection in Place Details.
placeList.addEventListener("gmp-placeselect", ({ place }) => {
markers[place.id].click();
});
@@ -61,20 +63,20 @@ async function addMarkers() {
markers[place.id] = marker;
bounds.extend(place.location);
marker.addListener('gmp-click', (event) => {
- if (infowindow.isOpen) {
- infowindow.close();
+ if (infoWindow.isOpen) {
+ infoWindow.close();
}
placeDetails.configureFromPlace(place);
placeDetails.style.width = "350px";
- infowindow.setOptions({
+ infoWindow.setOptions({
content: placeDetails
});
- infowindow.open({
+ infoWindow.open({
anchor: marker,
map: map.innerMap
});
placeDetails.addEventListener('gmp-load', () => {
- map.innerMap.fitBounds(place.viewport, { top: placeDetails.offsetHeight || 206, left: 200 });
+ map.innerMap.fitBounds(place.viewport, { top: 400, left: 200 });
});
});
map.innerMap.setCenter(bounds.getCenter());
diff --git a/dist/samples/ui-kit-place-search/docs/index.ts b/dist/samples/ui-kit-place-search/docs/index.ts
index f71fe30c..09e462d8 100644
--- a/dist/samples/ui-kit-place-search/docs/index.ts
+++ b/dist/samples/ui-kit-place-search/docs/index.ts
@@ -12,7 +12,7 @@ const placeDetails = document.querySelector("gmp-place-details") as any;
let marker = document.querySelector('gmp-advanced-marker') as any;
/* [END maps_ui_kit_place_search_query_selectors] */
let markers = {};
-let infowindow;
+let infoWindow;
let mapCenter;
async function initMap(): Promise
{
@@ -20,14 +20,16 @@ async function initMap(): Promise {
const { InfoWindow } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
const { spherical } = await google.maps.importLibrary("geometry") as google.maps.GeometryLibrary;
- infowindow = new google.maps.InfoWindow;
+ infoWindow = new google.maps.InfoWindow;
function getContainingCircle(bounds) {
const diameter = spherical.computeDistanceBetween(
bounds.getNorthEast(),
bounds.getSouthWest()
);
- return { center: bounds.getCenter(), radius: diameter / 2 };
+ const calculatedRadius = diameter / 2;
+ const cappedRadius = Math.min(calculatedRadius, 50000); // Cap the radius to avoid an error.
+ return { center: bounds.getCenter(), radius: cappedRadius };
}
findCurrentLocation();
@@ -41,7 +43,6 @@ async function initMap(): Promise {
typeSelect.addEventListener("change", (event) => {
// First remove all existing markers.
for(marker in markers){
- console.log(marker);
markers[marker].map = null;
}
markers = {};
@@ -53,7 +54,7 @@ async function initMap(): Promise {
),
includedPrimaryTypes: [typeSelect.value],
}).then(addMarkers);
-
+ // Handle user selection in Place Details.
placeList.addEventListener("gmp-placeselect", ({ place }) => {
markers[place.id].click();
});
@@ -79,20 +80,20 @@ async function addMarkers(){
bounds.extend(place.location);
marker.addListener('gmp-click',(event) => {
- if(infowindow.isOpen){
- infowindow.close();
+ if(infoWindow.isOpen){
+ infoWindow.close();
}
placeDetails.configureFromPlace(place);
placeDetails.style.width = "350px";
- infowindow.setOptions({
+ infoWindow.setOptions({
content: placeDetails
});
- infowindow.open({
+ infoWindow.open({
anchor: marker,
map: map.innerMap
});
placeDetails.addEventListener('gmp-load',() => {
- map.innerMap.fitBounds(place.viewport, {top: placeDetails.offsetHeight || 206, left: 200});
+ map.innerMap.fitBounds(place.viewport, { top: 400, left: 200 });
});
});
diff --git a/dist/samples/ui-kit-place-search/docs/style.css b/dist/samples/ui-kit-place-search/docs/style.css
index d432723d..90b4c949 100644
--- a/dist/samples/ui-kit-place-search/docs/style.css
+++ b/dist/samples/ui-kit-place-search/docs/style.css
@@ -24,9 +24,12 @@ html,
gmp-map {
box-sizing: border-box;
padding: 0 20px 20px;
+ height: 600px;
}
.overlay {
+ position: relative;
+ top: 40px;
margin: 20px;
width: 400px;
}
@@ -55,7 +58,7 @@ html,
}
.list-container {
- height: 600px;
+ height: 400px;
overflow: auto;
border-radius: 10px;
}
diff --git a/dist/samples/ui-kit-place-search/jsfiddle/demo.css b/dist/samples/ui-kit-place-search/jsfiddle/demo.css
index 48abcbea..d78d3bb5 100644
--- a/dist/samples/ui-kit-place-search/jsfiddle/demo.css
+++ b/dist/samples/ui-kit-place-search/jsfiddle/demo.css
@@ -24,9 +24,12 @@ html,
gmp-map {
box-sizing: border-box;
padding: 0 20px 20px;
+ height: 600px;
}
.overlay {
+ position: relative;
+ top: 40px;
margin: 20px;
width: 400px;
}
@@ -55,7 +58,7 @@ html,
}
.list-container {
- height: 600px;
+ height: 400px;
overflow: auto;
border-radius: 10px;
}
diff --git a/dist/samples/ui-kit-place-search/jsfiddle/demo.html b/dist/samples/ui-kit-place-search/jsfiddle/demo.html
index 68cff270..82a21d8d 100644
--- a/dist/samples/ui-kit-place-search/jsfiddle/demo.html
+++ b/dist/samples/ui-kit-place-search/jsfiddle/demo.html
@@ -13,7 +13,6 @@
- Place List Nearby Search with Google Maps
diff --git a/dist/samples/ui-kit-place-search/jsfiddle/demo.js b/dist/samples/ui-kit-place-search/jsfiddle/demo.js
index 68b73f6e..30b18ea3 100644
--- a/dist/samples/ui-kit-place-search/jsfiddle/demo.js
+++ b/dist/samples/ui-kit-place-search/jsfiddle/demo.js
@@ -12,16 +12,18 @@ const placeDetails = document.querySelector("gmp-place-details");
let marker = document.querySelector('gmp-advanced-marker');
/* [END maps_ui_kit_place_search_query_selectors] */
let markers = {};
-let infowindow;
+let infoWindow;
let mapCenter;
async function initMap() {
await google.maps.importLibrary("places");
const { InfoWindow } = await google.maps.importLibrary("maps");
const { spherical } = await google.maps.importLibrary("geometry");
- infowindow = new google.maps.InfoWindow;
+ infoWindow = new google.maps.InfoWindow;
function getContainingCircle(bounds) {
const diameter = spherical.computeDistanceBetween(bounds.getNorthEast(), bounds.getSouthWest());
- return { center: bounds.getCenter(), radius: diameter / 2 };
+ const calculatedRadius = diameter / 2;
+ const cappedRadius = Math.min(calculatedRadius, 50000); // Cap the radius to avoid an error.
+ return { center: bounds.getCenter(), radius: cappedRadius };
}
findCurrentLocation();
map.innerMap.setOptions({
@@ -32,7 +34,6 @@ async function initMap() {
typeSelect.addEventListener("change", (event) => {
// First remove all existing markers.
for (marker in markers) {
- console.log(marker);
markers[marker].map = null;
}
markers = {};
@@ -41,6 +42,7 @@ async function initMap() {
locationRestriction: getContainingCircle(map.innerMap.getBounds()),
includedPrimaryTypes: [typeSelect.value],
}).then(addMarkers);
+ // Handle user selection in Place Details.
placeList.addEventListener("gmp-placeselect", ({ place }) => {
markers[place.id].click();
});
@@ -61,20 +63,20 @@ async function addMarkers() {
markers[place.id] = marker;
bounds.extend(place.location);
marker.addListener('gmp-click', (event) => {
- if (infowindow.isOpen) {
- infowindow.close();
+ if (infoWindow.isOpen) {
+ infoWindow.close();
}
placeDetails.configureFromPlace(place);
placeDetails.style.width = "350px";
- infowindow.setOptions({
+ infoWindow.setOptions({
content: placeDetails
});
- infowindow.open({
+ infoWindow.open({
anchor: marker,
map: map.innerMap
});
placeDetails.addEventListener('gmp-load', () => {
- map.innerMap.fitBounds(place.viewport, { top: placeDetails.offsetHeight || 206, left: 200 });
+ map.innerMap.fitBounds(place.viewport, { top: 400, left: 200 });
});
});
map.innerMap.setCenter(bounds.getCenter());