
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Enable the Google Maps API
/ 10
Install the Vertex AI SDK and Python libraries
/ 10
Use a prompt to get hotel recommendations
/ 10
Use the Google Maps API to retrieve details about the hotel
/ 15
Use the Google Maps API to retrieve more details about a hotel
/ 15
Use the Google Maps API to get recommendations for a nearby restaurant
/ 15
Create the restaurant recommendation email
/ 25
Vertex AI Studio is a tool for prototyping and customizing generative AI models. Vertex AI offers access to Gemini multimodal models from Google, which are capable of understanding virtually any input, combining different types of information, and generating almost any output.
You are an Application Developer and/or DevOps Engineer for a Travel and Entertainment company. The company hires you to build, and test proof of concept code snippets for an upcoming Travel Agent app that's built on the Gemini Pro model, the Vertex AI Python SDK, and the Google Maps API.
In this lab, you assist the travel agency to provide improved hotel recommendations through chat. To that end, this lab provides an app that uses Gemini and the Google Maps API to provide prompt responses to recommend hotels and nearby restaurants. You review the provided script, enable the Google Maps API, and then use prompts to test the script.
In this lab, you learn how to perform the following tasks:
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the left is the Lab Details pane with the following:
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
If necessary, copy the Username below and paste it into the Sign in dialog.
You can also find the Username in the Lab Details pane.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
You can also find the Password in the Lab Details pane.
Click Next.
Click through the subsequent pages:
After a few moments, the Google Cloud console opens in this tab.
Google Maps API retrieves detailed information about hotels and restaurants. Perform the steps that follow to enable the Google Maps API:
In the Google Cloud console, on the Navigation menu (), click Google Maps Platform.
In the Learn map-making essentials section, click the Enable APIs tab.
In the Finish setup section, click Enable APIs.
When a Preview APIs button displays, this means all necessary APIs are enabled.
Click Check my progress to verify the objective.
Perform the steps that follow to create an API key so your app can access the Google Maps API:
Still in the Google Maps Platform window, click Google Maps Platform (in the upper left), and then Keys & Credentials.
Click Create credentials > API key.
When the API key created window opens, record Your API key to use later in the lab.
Click Close.
Open the notebook file in Vertex AI Workbench and then set up your JupyterLab environment.
In the Google Cloud console, on the Navigation menu (), click Vertex AI > Workbench.
Find the
The JupyterLab interface for your Workbench instance opens in a new browser tab.
The
In the Select Kernel dialog, choose Python 3 from the list of available kernels.
From this point forward, follow the steps in
agent-v1.0.0.ipynb
notebook file includes instructions on when to return to these lab instructions to Check your progress and score your progress.
In this section, you capture the Project ID, region, and Google Maps API key as variables so the values can be used later on in the notebook.
Content to replace | Replace with … |
---|---|
GOOGLE MAPS API KEY | <API-key-you recorded earlier> |
After you replace the content, the code should be similar to the following:
You may receive a warning message in red text like the one that follows. This is not an error message and should be ignored because in the case of this lab, Tensorflow is not being used.
Click Check my progress to verify the objective.
In this task, you review the code included in Task 2 of the notebook, and modify the sample prompt with your custom prompt based upon the requirements specified.
After running the steps in Task 2 in the notebook file, your output should be a list of hotels, each formatted similar to the following.
Output:
**1. The Trafalgar St. James:**
* Address: 2 Spring Gardens, St. James's, London SW1A 2TS
* Room rate: From £499 per night (approximately $605 USD)
* Distance to Trafalgar Square: 150 meters (2-minute walk)
* Amenities: Free Wi-Fi, restaurant, bar, fitness center, spa
* Website: https://www. thetrafalgarstjames.com/
These hotels offer a variety of styles and amenities, all within walking distance of Trafalgar Square and within your budget of $500 per night.
**Please note:** Prices may vary depending on the specific dates of your stay and availability.
**Additional options:**
* Consider using booking websites like Booking.com or Expedia to compare prices and find deals.
* Look into apartment rentals through Airbnb for a more local experience.
* Check out hostels for a budget-friendly option, especially if you are a solo traveler.
I hope this helps you find the perfect hotel for your trip to London!
Click Check my progress to verify the objective.
In this task, you save the hotel you want to stay at for your vacation, and use your Google Maps API key to retrieve the geocode results data from Google Maps. You then use this data to retrieve the location and place id.
Output:
[{'address_components': [{'long_name': '2',
'short_name': '2',
'types': ['street_number']},
{'long_name': 'Spring Gardens',
'short_name': 'Spring Gardens',
'types': ['route']},
{'long_name': 'Trafalgar Square',
'short_name': 'Trafalgar Sq',
'types': ['route']},
{'long_name': 'London',
'short_name': 'London',
'types': ['postal_town']},
...
'formatted_address': '2 Spring Gardens, Trafalgar Sq, London SW1A 2TS, UK',
'geometry': {'location': {'lat': 51.5073516, 'lng': -0.1291865},
'location_type': 'ROOFTOP',
'viewport': {'northeast': {'lat': 51.5086722302915,
'lng': -0.127766569708498},
'southwest': {'lat': 51.5059742697085,
'lng': -0.130464530291502}}},
'navigation_points': [{'location': {'latitude': 51.5073006,
'longitude': -0.1290871}}],
'partial_match': True,
'place_id': 'ChIJt2xYKc4EdkgRiSOCe1hI2zU',
'plus_code': {'compound_code': 'GV4C+W8 London, UK',
'global_code': '9C3XGV4C+W8'},
'types': ['establishment', 'lodging', 'point_of_interest']}]
pprint
to display the JSON stored in geocode_result
and has been truncated to keep this lab manual brief, but toward the bottom of the output you should notice the place ID for the hotel, which you can retrieve from geocode_result
using the code in the following Cell 15.place_id
from the Cell 14 output. Don’t forget to include quotes. Run the cell.
The resulting code should resemble the following:You should see the hotel’s Place ID in the output.
Click Check my progress to verify the objective.
In this task, you use the place ID to retrieve details about the hotel from the maps API. From the results of this function call you retrieve the hotel name (as a confirmation), the hotel address and the international phone number. This information is added to the restaurant recommendation email in a later task. You also retrieve and print the first review for the hotel, and retrieve the URL for all associated photos.
Run Cell 16 and Cell 17.
Review the output of Cell 17, you should see reviews of the hotel.
Cell 18 - Run this cell to retrieve, store, and print the hotel name, the address, and the international phone number. These get added to the restaurant recommendation email in the last task. The code should resemble the following:
The output should be the name, address and international phone number printed with pprint
, similar to the following.
Output:
'The Zetter Marylebone'
'28-30 Seymour St, London W1H 7JB, UK'
'+44 20 7324 4544'
Cell 19 - Run the cell to print the first hotel review by using pprint
.
The code should resemble the following:
Click Check my progress to verify the objective.
For this task, you use the Google Maps API nearby search feature, the hotel geo-coordinates (latitude and longitude), and the radius parameter to get recommendations for a sushi restaurant nearby the hotel you selected in Task 1.
Cell 21 - Run the cell to save the hotel geo-coordinates as two variables, latitude and longitude.
You need the latitude and longitude to find nearby locations, like restaurants, in the following cell. The code in the cell should resemble the following:
And the output should be the coordinates printed.
Output:
51.51487710000001
-0.1586355
Review the Supported Types documentation for the Place API. This link provides place_type
parameters you can include in the URL string to specify what you are looking for.
Cell 22 - Run the cell. The code accomplishes the following:
place_type
parameter list, uses sushi_restaurant
as the keyword.and looks similar to the code below.
Output:
{'business_status': 'OPERATIONAL',
'geometry': {'location': {'lat': 51.5192753, 'lng': -0.1628414},
'viewport': {'northeast': {'lat': 51.52058817989273,
'lng': -0.1614787701072778},
'southwest': {'lat': 51.51788852010728,
'lng': -0.1641784298927222}}},
'icon': 'https://maps.gstatic.com/mapfiles/place_api/icons/v1/png_71/restaurant-71.png',
'icon_background_color': '#FF9E67',
'icon_mask_base_uri': 'https://maps.gstatic.com/mapfiles/place_api/icons/v2/restaurant_pinlet',
'name': 'The Sushi Co - Marylebone',
'opening_hours': {'open_now': False},
'photos': [{'height': 1282,
'html_attributions': ['A '
'Google User'],
'photo_reference': 'ATplDJblS0m6KJkY5BBTdzlaqS1DQlC4KReTqWyBtBp3gXahH2eJJVWEGU-VTItBytk-nUZH8EI27BYoRVar2CJBc0jOhkL7nWzDamZtq5vmfUVxrq5-7TFf3ZHrK4Zc2ZiF1JQwthZYPplAzXgmzWk2ROKH0j2ApxM8GjXQYhEsfOY0-OZi',
'width': 1920}],
'place_id': 'ChIJUTYMRn8bdkgR86ABd3dNCbM',
'plus_code': {'compound_code': 'GR9P+PV London', 'global_code': '9C3XGR9P+PV'},
'rating': 4.7,
'reference': 'ChIJUTYMRn8bdkgR86ABd3dNCbM',
'scope': 'GOOGLE',
'types': ['restaurant', 'food', 'point_of_interest', 'establishment'],
'user_ratings_total': 197,
'vicinity': '48 Crawford St, London'}
Run the code in Cell 25 to set the nearby_restaurant
variable to the place-id
for the restaurant.
The code should resemble the following:
The output should be a place ID similar to the following output example.
Output:
ChIJUTYMRn8bdkgR86ABd3dNCbM
Run Cell 26 to include the place ID variable for the restaurant you stored in the previous step.
Run Cell 27 and observe the output, which is the Google Maps details of the sushi restaurant.
Run Cell 28 to store the restaurant name, first review, and Google Maps URL for the sushi restaurant.
The code should resemble the following:
The output should resemble the following.
Output:
'The Sushi Co - Marylebone'
{'author_name': 'Griff Hayward',
'author_url': 'https://www.google.com/maps/contrib/103419765716576164680/reviews',
'language': 'en',
'original_language': 'en',
'profile_photo_url': 'https://lh3.googleusercontent.com/a-/ALV-UjVOPUa51gCmHN5C64Jxf0_D2zx-QULivnjjNTgU_mYJqg=s128-c0x00000000-cc-rp-mo-ba4',
'rating': 4,
'relative_time_description': '3 months ago',
'text': 'Review for the sushi co Kensington, as it wouldn’t let me review '
'it.\n'
'\n'
'The food here was very nice and the staff were helpful and friendly, '
'however, the service was extremely slow, especially considering that '
'the restaurant was pretty much empty on a Tuesday evening. The sushi '
'was very good, but it did feel pretty difficult to order a full meal '
'as the cheapest actual sushi box with a proper selection was around '
'£26, although the prices were generally fair. I was told that the '
'Curries and ramen were underwhelming.\n'
'Overall, very tasty sushi and a nice setting, but with a very '
'western feel as far as sushi goes. Very weird that they wouldn’t let '
'me add photos, so I’ve put the photos for this place on the '
'Marylebone sight.',
'time': 1700396289,
'translated': False}
'https://maps.google.com/?cid=12900927783072538867'
Click Check my progress to verify the objective.
For this task, you use Gemini Pro to create a restaurant recommendation email based on details you collected throughout the lab for the hotel and the sushi restaurant, including the following:
Run Cell 28 to use the Gemini Pro GenerativeModel
to complete the creation of the model_restaurant
model.
The code should resemble the following:
Run Cell 29 and Cell 30.
Run Cell 31 so that the international phone number is included in the resulting email.
The code should resemble the following:
Run Cell 32. Observe the output. You should see an email template created with the details you collected throughout your work in this notebook, including:
The output should be similar to the following.
Output:
Your customer email:
Subject: Delightful Dining Recommendation near The Zetter Marylebone
Dear [Customer's name],
We hope you are having a wonderful stay at The Zetter Marylebone.
For your dining pleasure, we highly recommend The Sushi Co - Marylebone, just a stone's throw away from the hotel.
This cozy restaurant offers a delectable array of authentic Japanese cuisine, with a special emphasis on fresh and flavorful sushi. One satisfied customer recently shared their experience on Google Maps:
"The food here was very nice, and the staff were helpful and friendly. The sushi was very good, but it did feel pretty difficult to order a full meal as the cheapest actual sushi box with a proper selection was around £26. Overall, very tasty sushi and a nice setting."
For further information and to explore the menu, please visit their Google Maps listing here: https://maps.google.com/?cid=12900927783072538867
We believe The Sushi Co - Marylebone is the perfect spot to satisfy your cravings for authentic Japanese flavors. Please do not hesitate to contact us if you have any questions or require further assistance.
Thank you for choosing The Zetter Marylebone. We hope you have a memorable and enjoyable stay.
Best regards,
[Your name]
Marketing Director
The Zetter Marylebone
+44 20 7324 4544
28-30 Seymour St, London W1H 7JB, UK
Click Check my progress to verify the objective.
In this lab, you have learned how to develop a GenAI application with Gemini and Google Maps.
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated May 22, 2025
Lab Last Tested May 22, 2025
Copyright 2025 Google LLC. All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one