این محصول یا ویژگی در وضعیت Legacy است. برای اطلاعات بیشتر درباره وضعیت Legacy به محصولات و ویژگی های Legacy مراجعه کنید. برای انتقال به Places API (جدید)، به راهنمای مهاجرت مراجعه کنید.
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
توسعه دهندگان منطقه اقتصادی اروپا (EEA).
میتوانید از Places SDK برای Android برای درخواست عکس مکان برای نمایش در برنامه خود استفاده کنید. عکسهای ارائهشده توسط سرویس عکسها از منابع مختلفی از جمله صاحبان مشاغل و عکسهای ارائهشده توسط کاربر میآیند.
Places SDK برای اندروید یک تصویر بیت مپ را با حداکثر اندازه 1600 در 1600 پیکسل برمی گرداند.
فرآیند بازیابی عکس
برای بازیابی یک تصویر برای یک مکان:
از Place Details برای واکشی یک شی Place استفاده کنید (از fetchPlace() یا findCurrentPlace() استفاده کنید). حتماً فیلد Place.Field PHOTO_METADATAS را در لیست فیلدهایی که باید در شیء پاسخ Place گنجانده شود، قرار دهید.
یک شی FetchPhotoRequest ایجاد کنید، به صورت اختیاری حداکثر ارتفاع و عرض (بر حسب پیکسل) را مشخص کنید. عکس ها می توانند حداکثر عرض یا ارتفاع 1600 پیکسل داشته باشند.
یک OnSuccessListener اضافه کنید و عکس را از FetchPhotoResponse دریافت کنید.
عکس بگیر
مثال زیر گرفتن عکس مکان را نشان می دهد:
کاتلین
// Define a Place ID.valplaceId="INSERT_PLACE_ID_HERE"// Specify fields. Requests for photos must always have the PHOTO_METADATAS field.valfields=listOf(Place.Field.PHOTO_METADATAS)// Get a Place object (this example uses fetchPlace(), but you can also use findCurrentPlace())valplaceRequest=FetchPlaceRequest.newInstance(placeId,fields)placesClient.fetchPlace(placeRequest).addOnSuccessListener{response:FetchPlaceResponse->
valplace=response.place// Get the photo metadata.valmetada=place.photoMetadatasif(metada==null||metada.isEmpty()){Log.w(TAG,"No photo metadata.")return@addOnSuccessListener}valphotoMetadata=metada.first()// Get the attribution text.valattributions=photoMetadata?.attributions// Create a FetchPhotoRequest.valphotoRequest=FetchPhotoRequest.builder(photoMetadata).setMaxWidth(500)// Optional..setMaxHeight(300)// Optional..build()placesClient.fetchPhoto(photoRequest).addOnSuccessListener{fetchPhotoResponse:FetchPhotoResponse->
valbitmap=fetchPhotoResponse.bitmapimageView.setImageBitmap(bitmap)}.addOnFailureListener{exception:Exception->
if(exceptionisApiException){Log.e(TAG,"Place not found: "+exception.message)valstatusCode=exception.statusCodeTODO("Handle error with given status code.")}}}
جاوا
// 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.finalStringattributions=photoMetadata.getAttributions();// Create a FetchPhotoRequest.finalFetchPhotoRequestphotoRequest=FetchPhotoRequest.builder(photoMetadata).setMaxWidth(500)// Optional..setMaxHeight(300)// Optional..build();placesClient.fetchPhoto(photoRequest).addOnSuccessListener((fetchPhotoResponse)->{Bitmapbitmap=fetchPhotoResponse.getBitmap();imageView.setImageBitmap(bitmap);}).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 برگردانده شده شامل هر یک از انواع انتساب است، باید در هر کجا که تصویر را نمایش می دهید، انتساب را در برنامه خود قرار دهید. برای اطلاعات بیشتر، به نمایش اسناد اشاره کنید.
استفاده و صورتحساب
برای تماس با fetchPhoto() یک Places Photo SKU هزینه می شود. برای جزئیات به صفحه استفاده و صورتحساب مراجعه کنید.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Place Photos\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\nYou can use the Places SDK for Android to request a place photo to\ndisplay in your application. Photos returned by the photos service come from a\nvariety of sources, including business owners and user-contributed photos.\n\nPlaces SDK for Android returns a bitmap image with a maximum\nsize of 1600 by 1600 pixels.\n\nPhoto retrieval process\n-----------------------\n\nTo retrieve an image for a place:\n\n1. Use [Place Details](/maps/documentation/places/android-sdk/legacy/place-details) to fetch a `Place` object (use either [`fetchPlace()`](/maps/documentation/places/android-sdk/legacy/reference/com/google/android/libraries/places/api/net/PlacesClient#fetchPlace(com.google.android.libraries.places.api.net.FetchPlaceRequest)) or [`findCurrentPlace()`](/maps/documentation/places/android-sdk/legacy/reference/com/google/android/libraries/places/api/net/PlacesClient#findCurrentPlace(com.google.android.libraries.places.api.net.FindCurrentPlaceRequest))). 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/legacy/reference/com/google/android/libraries/places/api/net/FetchPlaceResponse) or [`FindCurrentPlaceResponse`](/maps/documentation/places/android-sdk/legacy/reference/com/google/android/libraries/places/api/net/FindCurrentPlaceResponse), use [`Place.getPhotoMetadas()`](/maps/documentation/places/android-sdk/legacy/reference/com/google/android/libraries/places/api/model/Place#getPhotoMetadatas()) to get the photo metadata object, of type [`PhotoMetadata`](/maps/documentation/places/android-sdk/legacy/reference/com/google/android/libraries/places/api/model/PhotoMetadata) from the response `Place` object.\n3. Create a [`FetchPhotoRequest`](/maps/documentation/places/android-sdk/legacy/reference/com/google/android/libraries/places/api/net/FetchPhotoRequest) object, optionally specifying maximum height and width (in pixels). Photos can have a maximum width or height of 1600px.\n4. Use [`PlacesClient.fetchPhoto()`](/maps/documentation/places/android-sdk/legacy/reference/com/google/android/libraries/places/api/net/PlacesClient#fetchPhoto(com.google.android.libraries.places.api.net.FetchPhotoRequest)) to request the photo bitmap.\n5. Add an `OnSuccessListener` and get the photo from the [`FetchPhotoResponse`](/maps/documentation/places/android-sdk/legacy/reference/com/google/android/libraries/places/api/net/FetchPhotoResponse).\n\nGet a photo\n-----------\n\nThe following example demonstrates getting a place photo: \n\n### Kotlin\n\n```kotlin\n// Define a Place ID.\nval placeId = \"INSERT_PLACE_ID_HERE\"\n\n// Specify fields. Requests for photos must always have the PHOTO_METADATAS field.\nval fields = listOf(Place.Field.PHOTO_METADATAS)\n\n// Get a Place object (this example uses fetchPlace(), but you can also use findCurrentPlace())\nval placeRequest = FetchPlaceRequest.newInstance(placeId, fields)\n\nplacesClient.fetchPlace(placeRequest)\n .addOnSuccessListener { response: FetchPlaceResponse -\u003e\n val place = response.place\n\n // Get the photo metadata.\n val metada = place.photoMetadatas\n if (metada == null || metada.isEmpty()) {\n Log.w(TAG, \"No photo metadata.\")\n return@addOnSuccessListener\n }\n val photoMetadata = metada.first()\n\n // Get the attribution text.\n val attributions = photoMetadata?.attributions\n\n // Create a FetchPhotoRequest.\n val photoRequest = FetchPhotoRequest.builder(photoMetadata)\n .setMaxWidth(500) // Optional.\n .setMaxHeight(300) // Optional.\n .build()\n placesClient.fetchPhoto(photoRequest)\n .addOnSuccessListener { fetchPhotoResponse: FetchPhotoResponse -\u003e\n val bitmap = fetchPhotoResponse.bitmap\n imageView.setImageBitmap(bitmap)\n }.addOnFailureListener { exception: Exception -\u003e\n if (exception is ApiException) {\n Log.e(TAG, \"Place not found: \" + exception.message)\n val statusCode = exception.statusCode\n TODO(\"Handle error with given status code.\")\n }\n }\n }\n\n \n```\n\n### Java\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.\n final String attributions = photoMetadata.getAttributions();\n\n // Create a FetchPhotoRequest.\n final FetchPhotoRequest photoRequest = FetchPhotoRequest.builder(photoMetadata)\n .setMaxWidth(500) // Optional.\n .setMaxHeight(300) // Optional.\n .build();\n placesClient.fetchPhoto(photoRequest).addOnSuccessListener((fetchPhotoResponse) -\u003e {\n Bitmap bitmap = fetchPhotoResponse.getBitmap();\n imageView.setImageBitmap(bitmap);\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 \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\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/legacy/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/legacy/reference/com/google/android/libraries/places/api/model/PhotoMetadata#public-abstract-string-getattributions).\n- **AuthorAttributions** , an [`AuthorAttributions`](/maps/documentation/places/android-sdk/legacy/reference/com/google/android/libraries/places/api/model/AuthorAttributions) object accessed by [`PhotoMetadata.getAuthorAttributions()`](/maps/documentation/places/android-sdk/legacy/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/legacy/attributions#photos).\n\nUsage and billing\n-----------------\n\nA **Places Photo** SKU is charged for calls to `fetchPhoto()`.\nSee the [Usage and Billing](/maps/documentation/places/android-sdk/legacy/usage-and-billing#places-photo-legacy-ent-sku) page for details."]]