Desarrolladores del Espacio Económico Europeo (EEE)
Place Photos (nuevo) te permite agregar contenido fotográfico de alta calidad a tu aplicación. Place Photos te brinda acceso a los millones de fotos almacenadas en la base de datos de Places. Place Photos devuelve un URI a una imagen de mapa de bits. La imagen de mapa de bits tiene un tamaño máximo de 4,800 por 4,800 píxeles.
Solicitudes de Place Photos
Para recuperar una imagen de un lugar, haz lo siguiente:
Usa Place Details (nuevo) para recuperar un objeto Place con fetchPlace().
Asegúrate de incluir el campo Place.Field PHOTO_METADATAS en la lista de campos que se incluirán en el objeto de respuesta Place.
Crea un objeto FetchResolvedPhotoUriRequest para realizar la solicitud y pasar el objeto de metadatos de la foto, así como los valores de altura máxima, ancho máximo o ambos.
Es el objeto de metadatos de la foto que se devolverá.
Altura máxima o ancho máximo
Especifica la altura y el ancho máximos, en píxeles, de la imagen que se devolverá. Si la imagen es más pequeña que los valores especificados, se devolverá la imagen original. Si la imagen es más grande en cualquiera de las dimensiones, se ajustará su escala para que coincida con la más pequeña de las dos dimensiones, restringida a su relación de aspecto original. Las propiedades de altura máxima y ancho máximo aceptan un número entero entre 1 y 4,800. Debes especificar la altura máxima, el ancho máximo o ambos.
Para establecer el parámetro de altura máxima, llama al método setMaxHeight() cuando compiles el objeto FetchResolvedPhotoUriRequest.
Para establecer el parámetro de ancho máximo, llama al método setMaxWidth() cuando compiles el objeto FetchResolvedPhotoUriRequest.
Ejemplos de Place Photos
En el siguiente ejemplo, se muestra cómo obtener el URI de una foto de lugar.
// 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.}});});
Atribuciones
En la mayoría de los casos, las fotos de lugares se pueden usar sin atribución o incluirán la atribución requerida como parte de la imagen. Sin embargo, el objeto de metadatos de la foto, del tipo PhotoMetadata, puede contener cualquiera de los dos tipos de atribuciones adicionales:
Si el objeto PhotoMetadata que se muestra incluye cualquiera de los tipos de atribución, debes incluir la atribución en tu aplicación en cualquier lugar donde muestres la imagen. Para obtener más información, consulta Cómo mostrar atribuciones.
[null,null,["Última actualización: 2025-08-30 (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)."]]