Place Photos

The Place Photo service, part of the Places API, is a read- only API that allows you to add high quality photographic content to your application. The Place Photo service gives you access to the millions of photos stored in the Places database. When you get place information using a Place Details request, photo references will be returned for relevant photographic content. Find Place, Nearby Search, and Text Search requests also return a single photo reference per place, when relevant. Using the Photo service you can then access the referenced photos and resize the image to the optimal size for your application.

Place Photo requests

A Place Photo request is an HTTP URL of the following form:

https://maps.googleapis.com/maps/api/place/photo?parameters

Certain parameters are required to initiate a search request. As is standard in URLs, all parameters are separated using the ampersand (&) character. The list of parameters and their possible values are enumerated below.

Required parameters

  • photo_reference

    A string identifier that uniquely identifies a photo. Photo references are returned from either a Place Search or Place Details request.

Optional parameters

  • maxheight

    Specifies the maximum desired height, in pixels, of the image. If the image is smaller than the values specified, the original image will be returned. If the image is larger in either dimension, it will be scaled to match the smaller of the two dimensions, restricted to its original aspect ratio. Both the maxheight and maxwidth properties accept an integer between 1 and 1600.

  • maxwidth

    Specifies the maximum desired width, in pixels, of the image. If the image is smaller than the values specified, the original image will be returned. If the image is larger in either dimension, it will be scaled to match the smaller of the two dimensions, restricted to its original aspect ratio. Both the maxheight and maxwidth properties accept an integer between 1 and 1600.

Generated from the OpenAPI specification. Edit Report bug

Photo references

All requests to the Place Photo service must include a photoreference, returned in the response to a Find Place, Nearby Search, Text Search, or Place Details request. The response to these requests will contain a photos[] field if the place has related photographic content.

Note: The number of photos returned varies by request.

  • A Find Place, Nearby Search, or Text Search request returns at most one photo element in the array.
  • A Place Details request returns up to ten photo elements.

Each photo element will contain the following fields:

  • photo_reference — a string used to identify the photo when you perform a Photo request.
  • height — the maximum height of the image.
  • width — the maximum width of the image.
  • html_attributions[] — contains any required attributions. This field will always be present, but may be empty.

Photos returned by the Photo service are sourced from a variety of locations, including business owners and user contributed photos. In most cases, these photos can be used without attribution, or will have the required attribution included as a part of the image. However, if the returned photo element includes a value in the html_attributions field, you will have to include the additional attribution in your application wherever you display the image.

An example of a photos[] array is shown below.

...
"photos" : [
   {
      "html_attributions" : [],
      "height" : 853,
      "width" : 1280,
      "photo_reference" : "CnRvAAAAwMpdHeWlXl-lH0vp7lez4znKPIWSWvgvZFISdKx45AwJVP1Qp37YOrH7sqHMJ8C-vBDC546decipPHchJhHZL94RcTUfPa1jWzo-rSHaTlbNtjh-N68RkcToUCuY9v2HNpo5mziqkir37WU8FJEqVBIQ4k938TI3e7bf8xq-uwDZcxoUbO_ZJzPxremiQurAYzCTwRhE_V0"
   }
...

Place Photo example

An example request is shown below. This request will return the referenced image, resizing it so that it is at most 400 pixels wide.

https://maps.googleapis.com/maps/api/place/photo
  ?maxwidth=400
  &photo_reference=Aap_uEA7vb0DDYVJWEaX3O-AtYp77AaswQKSGtDaimt3gt7QCNpdjp1BkdM6acJ96xTec3tsV_ZJNL_JP-lqsVxydG3nh739RE_hepOOL05tfJh2_ranjMadb3VoBYFvF0ma6S24qZ6QJUuV6sSRrhCskSBP5C1myCzsebztMfGvm7ij3gZT
  &key=YOUR_API_KEY

Place Photo response

The response of a successful Place Photo request will be an image. The type of the image will depend upon the type of the originally submitted photo.

If your request exceeds your available quota, the server will return an HTTP 403 status and display the below image to indicate that the quota has been exceeded:

Over Quota image

If the server is unable to understand your request, then it returns HTTP 400 status, which indicates an invalid request. The most common reasons for an invalid request include:

  • The submitted photo reference was not correctly specified.
  • The request did not include either the maxwidth or the maxheight parameters.
  • The value for either the maxwidth or the maxheight parameter was set to null.