Migrate to Place Photo (New)

Places API supports the existing Place Photo. If you are familiar with the existing Place Photo, the new version of Place Photo makes the following changes:

  • The new Place Photo service requires that you pass the resource name of the photo, which includes the place ID in the request URL, instead of just the photo reference. For more information, see Change to photo references.
  • The new Place Photo service supports both API keys and OAuth tokens as the authentication mechanism.

The following table lists parameters in the existing Place Photo that have been renamed or modified for the new Place Photo, or parameters that are no longer supported.

Current parameter New parameter Notes
maxheight maxHeightPx You must specify either maxHeightPx, maxWidthPx, or both.
maxwidth maxWidthPx You must specify either maxHeightPx, maxWidthPx, or both.

Increased photo size

The existing Place Photo supported a maximum photo size of 1600 by 1600 pixels. Place Photo (New) supports sizes up to 4800 by 4800 pixels.

Change to photo references

The new Place Photo API requires that you pass the resource name of the requested photo, which includes a place ID and the photo reference, in the form:

https://places.googleapis.com/v1/places/PLACE_ID/photos/PHOTO_REFERENCE/media?maxWidthPx=400&key=API_KEY

The new versions of Nearby Search, Text Search, and Place Details all return a photos[] array in the response that supports this format. Each element of photos[] in the new response contains the following fields:

  • name — A string containing the resource name of the photo. This string is in the form:

    places/PLACE_ID/photos/PHOTO_REFERENCE
  • heightPx — The maximum height of the image, in pixels.
  • widthPx — The maximum width of the image, in pixels.
  • authorAttributions[] — Any required attributions. This field is always present, but might be empty.

With the existing API, you only have to pass the photo reference, in the form:

https://maps.googleapis.com/maps/api/place/photo?photo_reference=PHOTO_REFERENCEmaxwidth=400&key=API_KEY

The existing Find Place, Nearby Search, Text Search, and Place Details all return a photos[] array in the response that supports this format. Each photo element in the existing response contains 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[] — Any required attributions. This field is always present, but might be empty.