[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThe Place Photo service provides access to millions of place photos stored in the Places database, allowing you to enhance your applications with high-quality imagery.\u003c/p\u003e\n"],["\u003cp\u003eYou can retrieve photo references through Place Details, Nearby Search, or Text Search requests and then use the Place Photo service to access and resize these photos.\u003c/p\u003e\n"],["\u003cp\u003ePlace Photo requests require a photo name, your API key, and either \u003ccode\u003emaxHeightPx\u003c/code\u003e or \u003ccode\u003emaxWidthPx\u003c/code\u003e (or both) to specify the desired image dimensions.\u003c/p\u003e\n"],["\u003cp\u003ePhoto names are obtained from Place Details, Nearby Search, or Text Search responses and must be used in your Place Photo requests to retrieve the actual images.\u003c/p\u003e\n"],["\u003cp\u003eEnsure your application includes any required attributions provided in the \u003ccode\u003eauthorAttributions\u003c/code\u003e field when displaying photos obtained through this service.\u003c/p\u003e\n"]]],[],null,["# Place Photos (New)\n\nSelect platform: [Android](/maps/documentation/places/android-sdk/place-photos \"View this page for the Android platform docs.\") [iOS](/maps/documentation/places/ios-sdk/place-photos \"View this page for the iOS platform docs.\") [Web Service](/maps/documentation/places/web-service/place-photos \"View this page for the Web Service platform docs.\") \n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nIntroduction\n------------\n\nThe [Place Photos (New)](/maps/documentation/places/web-service/reference/rest/v1/places.photos/getMedia)\nservice is a read-only API that lets you add high quality\nphotographic content to your application. Place Photos (New) gives\nyou access to the millions of photos stored in the Places database.\n\nWhen you get place information using a Place Details (New), Nearby Search (New), or\nText Search (New) request, you can also request photo resources for relevant photographic\ncontent. Using Place Photos (New), you can then access the referenced photos and resize the\nimage to the optimal size for your application.\n\nThe APIs Explorer lets you make live requests so that you can get familiar with\nthe API and the API options: \n[Try it!](#try_it)\n| **Note:** Enter the place `name` from the `photos` array of your [Place Details (New)](/maps/documentation/places/web-service/place-details) response body and click \"Execute.\" To view the photo, use the `photoUri` value in the Place Photos (New) response body.\n\nPlace Photos (New) requests\n---------------------------\n\nA Place Photos (New) request is an HTTP GET request to a URL in the form: \n\n```scdoc\nhttps://places.googleapis.com/v1/NAME/media?key=API_KEY&PARAMETERS\n```\n\nWhere the following parameters are required:\n\n- \u003cvar translate=\"no\"\u003eNAME\u003c/var\u003e contains the resource name of the photo.\n- \u003cvar translate=\"no\"\u003eAPI_KEY\u003c/var\u003e contains the API key.\n- \u003cvar translate=\"no\"\u003ePARAMETERS\u003c/var\u003e contains either the `maxHeightPx` parameter, the `maxWidthPx` parameter, or both.\n\nThe complete list of required and optional parameters are described below.\n\nRequired parameters\n-------------------\n\n### Photo name\n\nA string identifier that uniquely identifies a photo. Photo names are\nreturned from a [Place Details (New)](/maps/documentation/places/web-service/place-details),\n[Nearby Search (New)](/maps/documentation/places/web-service/nearby-search), or [Text Search (New)](/maps/documentation/places/web-service/text-search) request in the `name` property of each element of the\n`photos[]` array.\n\nFor an example, see [Get a photo name](#get-photo-ref).\n\n### maxHeightPx and maxWidthPx\n\nSpecifies the maximum intended height and width, in pixels, of the image. If the image is smaller\nthan the values specified, the original image will be returned. If the image is larger in either\ndimension, it will be scaled to match the smaller of the two dimensions, restricted to its original\naspect ratio. Both the maxheight and maxwidth properties accept an integer between 1 and 4800.\n\nYou must specify either `maxHeightPx`, or `maxWidthPx`, or both.\n\nOptional parameters\n-------------------\n\n### skipHttpRedirect\n\nIf `false` (default), make an HTTP redirect to the image to return the image.\nIf `true`, skip the redirect and return a JSON response containing the image details.\nFor example: \n\n```json\n{\n \"name\": \"places/ChIJj61dQgK6j4AR4GeTYWZsKWw/photos/Aaw_FcKly0DEv3EWmDJyHiEqXIP5mowOc99lN1GzBun6KHH52AZ5fFA/media\",\n \"photoUri\": \"https://lh3.googleusercontent.com/a-/AD_cFT-b=s100-p-k-no-mo\"\n}\n```\n\nThis option is ignored for non-HTTP requests.\n\nGet a photo name\n----------------\n\nAll requests to Place Photos (New) must include a photo resource\nname, returned in the response to a Nearby Search (New),\nText Search (New), or Place Details (New) request. The\nresponse to these requests contains a `photos[]` array if the\nplace has related photographic content.\n| **Note:** To include the `photos[]` array in the response, make sure to include `photos` (Place Details (New)) or `places.photos` (Nearby Search (New) and Text Search (New)) in the field mask of the request. Each API can return up to 10 photos for a place location.\n\nEach elements of `photo[]` contains the following fields:\n\n- `name` --- A string containing the resource name of the photo when you\n perform a Photo request. This string is in the form:\n\n ```\n places/PLACE_ID/photos/PHOTO_RESOURCE\n ```\n- `heightPx` --- The maximum height of the image, in pixels.\n- `widthPx` --- The maximum width of the image, in pixels.\n- `authorAttributions[]` --- Any required attributions. This field is always present, but might be empty.\n\nPhotos returned by Place Photos (New) are sourced from a variety of locations,\nincluding business owners and user contributed photos. In most cases, these\nphotos can be used without attribution, or will have the required attribution\nincluded as a part of the image. However, if the returned `photo` element\nincludes a value in the `authorAttributions` field, you must include the\nadditional attribution in your application wherever you display the image.\n| **Caution:** You cannot cache a photo name. Also, the name can expire. Ensure you always get the name from a response to a request to [Place Details (New)](/maps/documentation/places/web-service/place-details), [Nearby Search (New)](/maps/documentation/places/web-service/nearby-search), or [Text Search (New)](/maps/documentation/places/web-service/text-search). For more info, see the caching restrictions in Section 3.2.3(b)(No Caching) of the [Google Maps Platform Terms of Service](https://cloud.google.com/maps-platform/terms).\n\nThe following example shows a Place Details (New) request that\nincludes `photos` in the field mask so that the response\nincludes the `photos[]` array in the response: \n\n```\ncurl -X GET \\\n-H 'Content-Type: application/json' -H \"X-Goog-Api-Key: API_KEY\" \\\n-H \"X-Goog-FieldMask: id,displayName,photos\" \\\nhttps://places.googleapis.com/v1/places/ChIJ2fzCmcW7j4AR2JzfXBBoh6E\n```\nAn example of a `photos[]` array in the response is shown below. \n\n```json\n ...\n \"photos\" : [\n {\n \"name\": \"places/ChIJ2fzCmcW7j4AR2JzfXBBoh6E/photos/AUacShh3_Dd8yvV2JZMtNjjbbSbFhSv-0VmUN-uasQ2Oj00XB63irPTks0-A_1rMNfdTunoOVZfVOExRRBNrupUf8TY4Kw5iQNQgf2rwcaM8hXNQg7KDyvMR5B-HzoCE1mwy2ba9yxvmtiJrdV-xBgO8c5iJL65BCd0slyI1\",\n \"widthPx\": 6000,\n \"heightPx\": 4000,\n \"authorAttributions\": [\n {\n \"displayName\": \"John Smith\",\n \"uri\": \"//maps.google.com/maps/contrib/101563\",\n \"photoUri\": \"//lh3.googleusercontent.com/a-/AD_cFT-b=s100-p-k-no-mo\"\n }\n ]\n }, ...\n```\n\nRequest a place photo\n---------------------\n\nThe example request below returns an image using its resource `name`, resizing it so\nthat it is at most 400 pixels tall and wide: \n\n```json\nhttps://places.googleapis.com/v1/places/ChIJ2fzCmcW7j4AR2JzfXBBoh6E/photos/AUacShh3_Dd8yvV2JZMtNjjbbSbFhSv-0VmUN-uasQ2Oj00XB63irPTks0-A_1rMNfdTunoOVZfVOExRRBNrupUf8TY4Kw5iQNQgf2rwcaM8hXNQg7KDyvMR5B-HzoCE1mwy2ba9yxvmtiJrdV-xBgO8c5iJL65BCd0slyI1/media?maxHeightPx=400&maxWidthPx=400&key=\u003cvar translate=\"no\"\u003eAPI_KEY\u003c/var\u003e\n```\n\nThe [response](/maps/documentation/places/web-service/reference/rest/v1/places.photos/getMedia#response-body)\nof a successful Place Photos (New) request is an image.\nThe type of the image depends on the type of the originally submitted photo.\n\nError codes\n-----------\n\nPlace Photos (New) requests may return the following error codes.\n\n### Quota exceeded (403)\n\nIf your request exceeds your available quota, the server returns an\nHTTP 403 status and displays the following image to indicate that the quota has\nbeen exceeded:\n\n### Invalid request (404)\n\nIf the server is unable to understand your request, it returns HTTP 400\nstatus, which indicates an invalid request. The most common reasons for an\ninvalid request include:\n\n- The submitted photo name was not correctly specified.\n- The request did not include the `maxHeightPx` or the `maxWidthPx` parameter.\n- The value of the `maxHeightPx` or the `maxWidthtPx` parameter was set to `null`.\n- The `name` has expired. If `name` expires, make a request to [Place Details (New)](/maps/documentation/places/web-service/place-details), [Nearby Search (New)](/maps/documentation/places/web-service/nearby-search), or [Text Search (New)](/maps/documentation/places/web-service/text-search) to obtain a new `name`.\n\n### Too many requests (429)\n\nGoogle recommends loading photos on demand. If you attempt to show all images for a place at\nonce, the server may return an HTTP 429 status indicating loading too many photos at the same\ntime. If you receive this error message,\n[contact Support](/maps/documentation/places/web-service/support#contact-maps-support)\nand request a quota increase.\n\nTry it!\n-------\n\nThe API Explorer lets you make sample requests so\nthat you can get familiar with the API and the API options.\n\nTo make a request:\n\n1. Select the API icon api on the right side of the page.\n2. Set the `name` parameter to: \n\n ```yaml\n places/\u003cvar translate=\"no\"\u003ePLACE_ID\u003c/var\u003e/photos/\u003cvar translate=\"no\"\u003ePHOTO_RESOURCE\u003c/var\u003e/media\n ```\n | **Note:** Make sure you are using a `name` from a recent Place Details (New) request because the `name` can expire.\n3. Set `skipHttpRedirect` to `true` so that the request returns a JSON response. By default, the request returns the image, which cannot be displayed by the API Explorer.\n4. Select **Execute** button. In the dialog, choose the account that you want to use to make the request.\n5. In the API Explorer panel, select the fullscreen icon\n fullscreen to expand the API Explorer\n window."]]