The Places API accepts requests for place data through a variety of methods. The Places API response contains data about a place, including location data and imagery, geographic locations, and prominent points of interest.
With this release, the response from Text Search, Nearby Search, and Place Details can also contain links to Google Maps. Your users can browse to these Google Maps links to see additional information about a place in the response.
For example, you search for airports in San Francisco, California. The response
then includes San Francisco International Airport (SFO) in the list of places.
With this release, the
Place
object for SFO in the response adds the googleMapsUri
field containing
Google Maps links to open Google Maps to the place,
directions to the place, reviews of the place, and place photos.
Along with the links added to the Place
object, this release also adds the
googleMapsUri
field to the
Reviews
and
Photos
objects in the response:
Reviews.googleMapsUri
: Contains a Google Maps link to the review so you can view it in a browser.Photos.googleMapsUri
: Contains a Google Maps link to the photo so you can view it in a browser.
The API Explorer lets you make live requests so that you can get familiar with these new options:
Supported Google Maps links for a place
The following table shows the Google Maps links that you can include in the response:
Google Maps link | Description | Field name |
---|---|---|
Place | Link to open Google Maps to the place. | googleMapsLinks.placeUri |
Directions | Link to open directions to the place in Google Maps. | googleMapsLinks.directionsUri |
Write review | Link to write a review for the place in Google Maps. | googleMapsLinks.writeAReviewUri |
Read reviews | Link to show Google Maps reviews of the place. | googleMapsLinks.reviewsUri |
Photos | Link to show photos of the place in Google Maps. | googleMapsLinks.photosUri |
Pricing
This feature is in the pre-GA Preview stage and there is no charge, meaning billing is $0, for usage during Preview. For details on the proposed pricing, see Places API Usage and Billing.
Include all links in the Places response
The links in the places response are contained in the
googleMapsLinks
field. Make sure to include the googleMapsLinks
field in the field mask of the
request if you want them to appear in the response.
For example, the following Text Search includes all Maps links in the response:
curl -X POST -d '{ "textQuery" : "San Francisco International Airport" }' \ -H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \ -H 'X-Goog-FieldMask: places.displayName,places.formattedAddress,places.priceLevel,places.googleMapsLinks' \ 'https://places.googleapis.com/v1/places:searchText'
The response is in the form:
{ "places": [ { "formattedAddress": "San Francisco, CA 94128, USA", "displayName": { "text": "San Francisco International Airport", "languageCode": "en" }, "googleMapsLinks": { "placeUri": "https://maps.google.com/?cid=11885663895765773631", "directionsUri": "https://www.google.com/maps/dir//''/data=!4m7!4m6!1m1!4e2!1m2!1m1!1s0x808f778c55555555:0xa4f25c571acded3f!3e0", "writeAReviewUri": "https://www.google.com/maps/place//data=!4m3!3m2!1s0x808f778c55555555:0xa4f25c571acded3f!12e1", "reviewsUri": "https://www.google.com/maps/place//data=!4m4!3m3!1s0x808f778c55555555:0xa4f25c571acded3f!9m1!1b1", "photosUri": "https://www.google.com/maps/place//data=!4m3!3m2!1s0x808f778c55555555:0xa4f25c571acded3f!10e5" } } ] }
Include a specific link in the response
You don't have to return all links in the response. For example, if you only
want the photos link in the response, modify the field mask as shown below to
only include the photosUri
field:
curl -X POST -d '{ "textQuery" : "San Francisco International Airport" }' \ -H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \ -H 'X-Goog-FieldMask: places.displayName,places.formattedAddress,places.priceLevel,places.googleMapsLinks.photosURI' \ 'https://places.googleapis.com/v1/places:searchText'
Include directions in the response
All Places methods support the generation of the directions link in the response. The current location is used as the origin, the place location is used as the destination, and the travel mode is drive.
The next example uses Nearby Search to include the maps directions link in the
response in the directionsUri
field:
curl -X POST -d '{ "includedTypes": ["restaurant"], "maxResultCount": 10, "locationRestriction": { "circle": { "center": { "latitude": -33.8688, "longitude": 151.1957362}, "radius": 500.0 } } }' \ -H 'Content-Type: application/json' -H 'X-Goog-Api-Key:API_KEY' \ -H 'X-Goog-FieldMask: places.displayName,places.googleMapsLinks.directionsUri' \ https://places.googleapis.com/v1/places:searchNearby
Include reviews and photos links
This release adds the googleMapsUri
field to the
Reviews
and
Photos
objects in the response. Browsing to these links opens the review or photo in
Google Maps.
For example, the following Text Search includes reviews and photos for each place in the response:
curl -X POST -d '{ "textQuery" : "Spicy Vegetarian Food in Sydney, Australia" }' \ -H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \ -H 'X-Goog-FieldMask: places.displayName,places.reviews,places.photos' \ 'https://places.googleapis.com/v1/places:searchText'
In the response, each element of the reviews and photos array contains the
googleMapsUri
field to open the review or photo in a browser.
Try it!
The API Explorer lets you make sample requests so that you can get familiar with the API and the API options.
Select the API icon, , on the right side of the page.
Optionally expand Show standard parameters and set the
fields
parameter to the field mask.Optionally edit the Request body.
Select Execute button. In the dialog, choose the account that you want to use to make the request.
In the API Explorer panel, select the expand icon, , to expand the API Explorer window.