Place Photos (Yeni), uygulamanıza yüksek kaliteli fotoğraf içerikleri eklemenizi sağlar. Yer Fotoğrafları, Yerler veritabanında depolanan milyonlarca fotoğrafa erişmenizi sağlar. Place Photos, bir bit eşlem resminin URI'sini döndürür. Bit eşlem görüntünün maksimum boyutu 4.800 x 4.800 pikseldir.
Yerin Fotoğrafları istekleri
Bir yerin resmini almak için:
Yer Ayrıntıları (Yeni)'nı kullanarak fetchPlace() ile Place nesnesi getirin.
Place.Field PHOTO_METADATAS alanını, yanıt Place nesnesine dahil edilecek alanlar listesine eklediğinizden emin olun.
İsteği oluşturmak ve fotoğraf meta verileri nesnesinin yanı sıra maksimum yükseklik, maksimum genişlik veya her ikisi için de değerler iletmek üzere bir FetchResolvedPhotoUriRequest nesnesi oluşturun.
Döndürülecek resmin piksel cinsinden maksimum yüksekliğini ve genişliğini belirtir. Resim, belirtilen değerlerden küçükse orijinal resim döndürülür. Resim, boyutlardan herhangi birinde daha büyükse orijinal en boy oranı korunarak iki boyuttan daha küçük olanla eşleşecek şekilde ölçeklendirilir. Hem maksimum yükseklik hem de maksimum genişlik özellikleri 1 ile 4800 arasında bir tam sayı kabul eder. Maksimum yüksekliği, maksimum genişliği veya her ikisini de belirtmeniz gerekir.
Aşağıdaki örnekte, bir yer fotoğrafı URI'sinin nasıl alınacağı gösterilmektedir.
// 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.}});});
İlişkilendirmeler
Çoğu durumda, yer fotoğrafları atıfta bulunmadan kullanılabilir veya gerekli atıf, resmin bir parçası olarak eklenir. Ancak, PhotoMetadata türündeki fotoğraf meta verileri nesnesi, iki tür ek ilişkilendirmeden birini içerebilir:
Döndürülen PhotoMetadata nesnesi, atıf türlerinden birini içeriyorsa resmi uygulamanızda gösterdiğiniz her yerde atıfı da eklemeniz gerekir. Daha fazla bilgi için Atıfları Gösterme başlıklı makaleyi inceleyin.
[null,null,["Son güncelleme tarihi: 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)."]]