Skip to content

Commit 226ad8e

Browse files
committed
fix: Adds hard-coded bounds for location restriction.
1 parent b3b984d commit 226ad8e

File tree

1 file changed

+9
-3
lines changed
  • samples/ui-kit-place-search-text

1 file changed

+9
-3
lines changed

samples/ui-kit-place-search-text/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ let marker = document.querySelector('gmp-advanced-marker') as any;
1414
let markers = {};
1515
let infoWindow;
1616
let center = { lat: 37.395641, lng: -122.077627 };
17+
let bounds;
1718

1819
async function initMap(): Promise<void> {
19-
await google.maps.importLibrary("places");
20-
const { InfoWindow } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
20+
const { Map, InfoWindow } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary;
2121
const { Place } = await google.maps.importLibrary("places") as google.maps.PlacesLibrary;
2222

23+
// Set bounds for location restriction.
24+
bounds = new google.maps.LatLngBounds(
25+
{ lat: 37.37808200917261, lng: -122.13741583377849 },
26+
{ lat: 37.416676154341324, lng: -122.02261728794109 }
27+
);
28+
2329
infoWindow = new google.maps.InfoWindow;
2430

2531
// Center the map
@@ -40,7 +46,7 @@ async function initMap(): Promise<void> {
4046
async function searchByTextRequest(textQuery) {
4147
if (textQuery) {
4248
placeList.configureFromSearchByTextRequest({
43-
locationRestriction: map.innerMap.getBounds(),
49+
locationRestriction: bounds,
4450
includedType: "restaurant",
4551
textQuery: textQuery,
4652
}).then(addMarkers);

0 commit comments

Comments
 (0)