Place Photos (новое) позволяет добавлять в приложение высококачественный фотоконтент. Place Photos предоставляет доступ к миллионам фотографий, хранящихся в базе данных Places. Place Photos возвращает URI растрового изображения. Максимальный размер растрового изображения — 4800 на 4800 пикселей.
Запросы на размещение фотографий
Чтобы получить изображение места:
Используйте функцию «Сведения о месте (новое)» для получения объекта Place с помощью fetchPlace() . Обязательно включите поле Place.Field PHOTO_METADATAS в список полей для включения в ответ объекта Place .
Создайте объект FetchResolvedPhotoUriRequest для выполнения запроса и передачи объекта метаданных фотографии, а также значений максимальной высоты, максимальной ширины или обоих.
Объект метаданных фотографии, который необходимо вернуть.
Максимальная высота или максимальная ширина
Задаёт максимальную высоту и ширину возвращаемого изображения в пикселях. Если изображение меньше указанных значений, будет возвращено исходное изображение. Если изображение больше по одному из двух измерений, оно будет масштабировано до меньшего из двух измерений с сохранением исходного соотношения сторон. Свойства максимальной высоты и максимальной ширины принимают целые числа от 1 до 4800. Необходимо указать максимальную высоту, максимальную ширину или оба значения.
Чтобы задать максимальный параметр высоты, вызовите метод setMaxHeight() при построении объекта FetchResolvedPhotoUriRequest .
Чтобы задать максимальный параметр ширины, вызовите метод setMaxWidth() при построении объекта FetchResolvedPhotoUriRequest .
Примеры фотографий мест
В следующем примере демонстрируется получение URI фотографии места.
// Define a Place ID.finalStringplaceId="INSERT_PLACE_ID_HERE";// Specify fields. Requests for photos must always have the PHOTO_METADATAS field.finalList<Place.Field>fields=Collections.singletonList(Place.Field.PHOTO_METADATAS);// Get a Place object (this example uses fetchPlace(), but you can also use findCurrentPlace())finalFetchPlaceRequestplaceRequest=FetchPlaceRequest.newInstance(placeId,fields);placesClient.fetchPlace(placeRequest).addOnSuccessListener((response)->{finalPlaceplace=response.getPlace();// Get the photo metadata.finalList<PhotoMetadata>metadata=place.getPhotoMetadatas();if(metadata==null||metadata.isEmpty()){Log.w(TAG,"No photo metadata.");return;}finalPhotoMetadataphotoMetadata=metadata.get(0);// Get the attribution text and author attributions.finalStringattributions=photoMetadata.getAttributions();finalAuthorAttributionsauthorAttributions=photoMetadata.getAuthorAttributions();// Create a FetchResolvedPhotoUriRequest.finalFetchResolvedPhotoUriRequestphotoRequest=FetchResolvedPhotoUriRequest.builder(photoMetadata).setMaxWidth(500).setMaxHeight(300).build();// Request the photo URIplacesClient.fetchResolvedPhotoUri(photoRequest).addOnSuccessListener((fetchResolvedPhotoUriResponse)->{Uriuri=fetchResolvedPhotoUriResponse.getUri();RequestOptionsrequestOptions=newRequestOptions().override(Target.SIZE_ORIGINAL);Glide.with(this).load(uri).apply(requestOptions).into(imageView);}).addOnFailureListener((exception)->{if(exceptioninstanceofApiException){finalApiExceptionapiException=(ApiException)exception;Log.e(TAG,"Place not found: "+exception.getMessage());finalintstatusCode=apiException.getStatusCode();// TODO: Handle error with given status code.}});});
Атрибуции
В большинстве случаев фотографии мест можно использовать без указания авторства или с обязательным указанием авторства, включенным в изображение. Однако объект метаданных фотографии типа PhotoMetadata может содержать один из двух типов дополнительных указаний авторства:
Если возвращаемый объект PhotoMetadata содержит какой-либо тип атрибуции, необходимо включить эту атрибуцию в приложение при каждом отображении изображения. Подробнее см. в разделе Отображение атрибуции .
[null,null,["Последнее обновление: 2025-08-29 UTC."],[[["\u003cp\u003ePlace Photos (New) allows you to access and display millions of photos from the Google Places database in your application.\u003c/p\u003e\n"],["\u003cp\u003eTo retrieve a place photo, you must first fetch a \u003ccode\u003ePlace\u003c/code\u003e object using Place Details (New) with the \u003ccode\u003ePHOTO_METADATAS\u003c/code\u003e field, then use this metadata to request the photo URI via the Places SDK.\u003c/p\u003e\n"],["\u003cp\u003ePhoto requests require specifying either a maximum width, maximum height, or both, for the returned image, with the maximum resolution being 4800x4800 pixels.\u003c/p\u003e\n"],["\u003cp\u003eWhile most Place Photos can be used without attribution, some may require displaying attributions obtained from the \u003ccode\u003ePhotoMetadata\u003c/code\u003e object alongside the image.\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\n\u003cbr /\u003e\n\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\nPlace Photos (New) lets you add high quality photographic content to your\napplication. Place Photos gives you access to the millions of photos stored in\nthe Places database. Place Photos returns a URI to a bitmap image. The bitmap\nimage has a maximum size of 4800 by 4800 pixels.\n| **Note:** Place Photos (New) is available in Places SDK for Android version 3.4.0 and later. For more information, see [Choose your SDK\n| version](/maps/documentation/places/android-sdk/choose-sdk). For more information about using the Kotlin APIs added in version 4.0.0, see the [Reference\n| Overview](/maps/documentation/places/android-sdk/reference).\n\nPlace Photos requests\n---------------------\n\nTo retrieve an image for a place:\n\n1. Use [Place Details (New)](/maps/documentation/places/android-sdk/details-places) to fetch a `Place` object using [`fetchPlace()`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/PlacesClient#fetchPlace(com.google.android.libraries.places.api.net.FetchPlaceRequest)). Be sure to include the `Place.Field PHOTO_METADATAS` field in the list of fields to include in the response `Place` object.\n2. In the [`OnSuccessListener`](https://developer.android.com/reference/com/google/android/play/core/tasks/OnSuccessListener) for your [`FetchPlaceResponse`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/FetchPlaceResponse), call [`Place.getPhotoMetadas()`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/model/Place#getPhotoMetadatas()) to get the photo metadata object of type [`PhotoMetadata`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/model/PhotoMetadata) from the response `Place` object.\n3. Create a [`FetchResolvedPhotoUriRequest`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/FetchResolvedPhotoUriRequest.Builder) object to make the request and pass the photo metadata object, as well values for maximum height, maximum width, or both.\n4. Use [`PlacesClient.fetchResolvedPhotoUri()`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/PlacesClient#fetchResolvedPhotoUri(com.google.android.libraries.places.api.net.FetchResolvedPhotoUriRequest)) to request the photo URI.\n5. Add an `OnSuccessListener` and get the photo URI from the [`FetchResolvedPhotoUriResponse`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/FetchResolvedPhotoUriResponse) object.\n\n| **Note:** For more information on initializing `PlacesClient`, see [Initialize the Places API client](/maps/documentation/places/android-sdk/config#connect-client).\n| You can use a [CancellationToken](/android/reference/com/google/android/gms/tasks/CancellationToken)\n| to attempt to cancel a request to any of the request classes (for example,\n| `FetchPlaceRequest`). Cancellation is done on a best-effort basis.\n| Once a cancellation request is issued, no response will be returned.\n| **Issuing a cancellation token does NOT guarantee that a particular request\n| will be cancelled, and you may still be charged for the request even if no\n| response is returned**.\n\nRequired parameters\n-------------------\n\nThe required parameters for\n[`FetchResolvedPhotoUriRequest`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/FetchResolvedPhotoUriRequest.Builder)\nare:\n\n-\n\n ### Photo metadata\n\n The metadata object of the photo to return.\n-\n\n ### Maximum height or maximum width\n\n\n Specifies the maximum height and width, in pixels, of the image to return. 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 maximum height and maximum width properties accept an integer between 1 and 4800. You must specify maximum height, maximum width, or both.\n - To set the maximum height parameter, call the [setMaxHeight()](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/FetchResolvedPhotoUriRequest.Builder#public-abstract-fetchresolvedphotourirequest.builder-setmaxheight-integer-maxheight) method when building the `FetchResolvedPhotoUriRequest` object.\n - To set the maximum width parameter, call the [setMaxWidth()](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/net/FetchResolvedPhotoUriRequest.Builder#public-abstract-fetchresolvedphotourirequest.builder-setmaxwidth-integer-maxwidth) method when building the `FetchResolvedPhotoUriRequest` object.\n\nPlace Photos examples\n---------------------\n\nThe following example demonstrates getting a place photo URI. \n\n```java\n// Define a Place ID.\nfinal String placeId = \"INSERT_PLACE_ID_HERE\";\n\n// Specify fields. Requests for photos must always have the PHOTO_METADATAS field.\nfinal List\u003cPlace.Field\u003e fields = Collections.singletonList(Place.Field.PHOTO_METADATAS);\n\n// Get a Place object (this example uses fetchPlace(), but you can also use findCurrentPlace())\nfinal FetchPlaceRequest placeRequest = FetchPlaceRequest.newInstance(placeId, fields);\n\nplacesClient.fetchPlace(placeRequest).addOnSuccessListener((response) -\u003e {\n final Place place = response.getPlace();\n\n // Get the photo metadata.\n final List\u003cPhotoMetadata\u003e metadata = place.getPhotoMetadatas();\n if (metadata == null || metadata.isEmpty()) {\n Log.w(TAG, \"No photo metadata.\");\n return;\n }\n final PhotoMetadata photoMetadata = metadata.get(0);\n\n // Get the attribution text and author attributions.\n final String attributions = photoMetadata.getAttributions();\n final AuthorAttributions authorAttributions = photoMetadata.getAuthorAttributions();\n\n // Create a FetchResolvedPhotoUriRequest.\n final FetchResolvedPhotoUriRequest photoRequest = FetchResolvedPhotoUriRequest.builder(photoMetadata)\n .setMaxWidth(500)\n .setMaxHeight(300)\n .build();\n\n // Request the photo URI\n placesClient.fetchResolvedPhotoUri(photoRequest).addOnSuccessListener((fetchResolvedPhotoUriResponse) -\u003e {\n Uri uri = fetchResolvedPhotoUriResponse.getUri();\n RequestOptions requestOptions = new RequestOptions().override(Target.SIZE_ORIGINAL);\n Glide.with(this).load(uri).apply(requestOptions).into(imageView);\n }).addOnFailureListener((exception) -\u003e {\n if (exception instanceof ApiException) {\n final ApiException apiException = (ApiException) exception;\n Log.e(TAG, \"Place not found: \" + exception.getMessage());\n final int statusCode = apiException.getStatusCode();\n // TODO: Handle error with given status code.\n }\n });\n});\n```\n\nAttributions\n------------\n\nIn most cases, place photos can be used without attribution, or will have\nthe required attribution included as part of the image. However, the photo metadata object, of type\n[`PhotoMetadata`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/model/PhotoMetadata),\ncan contain either of two types of additional attributions:\n\n- **Attributions** , an attribution string accessed by [`PhotoMetadata.getAttributions()`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/model/PhotoMetadata#public-abstract-string-getattributions).\n- **AuthorAttributions** , an [`AuthorAttributions`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/model/AuthorAttributions) object accessed by [`PhotoMetadata.getAuthorAttributions()`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/api/model/PhotoMetadata#public-abstract-authorattributions-getauthorattributions).\n\nIf the returned `PhotoMetadata` object includes either type of attribution, you must\ninclude the attribution in your application wherever you display the image. For more information,\nsee [Displaying Attributions](/maps/documentation/places/android-sdk/attributions#photos)."]]