diff --git a/samples/ui-kit-place-search-text/index.ts b/samples/ui-kit-place-search-text/index.ts index 972c809b..04d9b880 100644 --- a/samples/ui-kit-place-search-text/index.ts +++ b/samples/ui-kit-place-search-text/index.ts @@ -14,12 +14,18 @@ let marker = document.querySelector('gmp-advanced-marker') as any; let markers = {}; let infoWindow; let center = { lat: 37.395641, lng: -122.077627 }; +let bounds; async function initMap(): Promise { - await google.maps.importLibrary("places"); - const { InfoWindow } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary; + const { Map, InfoWindow } = await google.maps.importLibrary("maps") as google.maps.MapsLibrary; const { Place } = await google.maps.importLibrary("places") as google.maps.PlacesLibrary; + // Set bounds for location restriction. + bounds = new google.maps.LatLngBounds( + { lat: 37.37808200917261, lng: -122.13741583377849 }, + { lat: 37.416676154341324, lng: -122.02261728794109 } + ); + infoWindow = new google.maps.InfoWindow; // Center the map @@ -40,7 +46,7 @@ async function initMap(): Promise { async function searchByTextRequest(textQuery) { if (textQuery) { placeList.configureFromSearchByTextRequest({ - locationRestriction: map.innerMap.getBounds(), + locationRestriction: bounds, includedType: "restaurant", textQuery: textQuery, }).then(addMarkers);