پوشاندن میدان مورد نیاز است. شما باید مشخص کنید که کدام فیلدها را می خواهید در پاسخ بازگردانید. هیچ لیست پیش فرضی از فیلدهای برگشتی وجود ندارد. اگر این لیست را حذف کنید، متدها با خطا مواجه می شوند.
پاسخ حاوی یک نمونه GMSPlace حاوی جزئیات مربوط به مکان است. مقادیر موجود در types نمونه GMSPlace اکنون توسط جدول A و جدول B تعریف میشوند.
نمونه پاسخ GMSPlace حاوی ویژگی reviews جدید از نوع GMSPlaceReview است. هنگامی که برنامه شما اطلاعات به دست آمده از نمونه GMSPlace ، مانند عکس ها و نظرات را نمایش می دهد، برنامه باید اسناد مورد نیاز را نیز نمایش دهد.
برای اطلاعات بیشتر، به اسناد مربوط به اسناد مراجعه کنید.
نمونه پاسخ GMSPlace شامل توابع عضو زیر است:
isOpen محاسبه می کند که آیا مکانی در زمان معین باز است یا خیر.
isOpenAtDate محاسبه می کند که آیا یک مکان در تاریخ معین باز است یا خیر.
این توابع تنها زمانی در دسترس هستند که Places SDK را برای iOS فعال کنید. وقتی Places SDK برای iOS (جدید) را فعال میکنید، در دسترس نیستند. برای اطلاعات بیشتر، به انتخاب نسخه SDK خود مراجعه کنید.
درخواست نمونه
با Place Details (جدید)، شما درخواست می کنید و تمام پارامترها را در نمونه GMSFetchPlaceRequest ارسال می کنید. این مثال همچنین از یک فیلد ماسک استفاده می کند، بنابراین پاسخ فقط شامل نام نمایشی و URL وب سایت برای مکان است:
سویفت
// A hotel in Saigon with an attribution.letplaceID="ChIJV4k8_9UodTERU5KXbkYpSYs"// Specify the place data types to return.letfields=[GMSPlaceProperty.name,GMSPlaceProperty.website].map{$0.rawValue}// Create the GMSFetchPlaceRequest instance.letfetchPlaceRequest=GMSFetchPlaceRequest(placeID:placeID,placeProperties:fields,sessionToken:nil)client.fetchPlaceWithRequest(fetchPlaceRequest:fetchPlaceRequest,callback:{(place:GMSPlace?,error:Error?)inguardletplace,error==nilelse{return}print("Place found: \(String(describing:place.name))")})
هدف-C
// A hotel in Saigon with an attribution.NSString*placeID=@"ChIJV4k8_9UodTERU5KXbkYpSYs";// Specify the place data types to return.NSArray<NSString*>*fields=@[GMSPlacePropertyName,GMSPlacePropertyWebsite];// Create the GMSFetchPlaceRequest instance.GMSFetchPlaceRequest*fetchPlaceRequest=[[GMSFetchPlaceRequestalloc]initWithPlaceID:placeIDplaceProperties:fieldssessionToken:nil];[placesClientfetchPlaceWithRequest:fetchPlaceRequestcallback:^(GMSPlace*_Nullableplace,NSError*_Nullableerror){if(error!=nil){NSLog(@"An error occurred %@",[errorlocalizedDescription]);return;}else{NSLog(@"Place Found: %@",place.name);NSLog(@"The place URL: %@",place.website);}}];
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Migrate to Place Details (New)\n\n\u003cbr /\u003e\n\n| This feature requires that you enable Places API (New), the next generation of the Places API. For more information, see [Enable APIs](/maps/documentation/places/ios-sdk/legacy/cloud-setup#enabling-apis).\n\n\u003cbr /\u003e\n\nPlaces SDK for iOS supports\n[Place Details (Legacy)](/maps/documentation/places/ios-sdk/place-details).\nIf you are familiar with Places SDK for iOS (Legacy),\n[Place Details (New)](/maps/documentation/places/ios-sdk/details-place)\nmakes the following changes:\n\n- Uses a new pricing model. For pricing information for all APIs, see\n [Pricing for the Places SDK for iOS (New)](/maps/documentation/places/ios-sdk/usage-and-billing#pricing-new).\n\n- Field masking is required. You must specify which fields you want returned\n in the response. There is no default list of returned fields. If you omit\n this list, the methods return an error.\n\n- To make a request, call the new\n [`GMSPlacesClient fetchPlaceWithRequest:`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlacesClient#-fetchplacewithrequest:callback:)\n method.\n\n- Pass to the request:\n\n - An instance of the new\n [`GMSFetchPlaceRequest`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSFetchPlaceRequest)\n class that defines all request parameters, such as the place ID and\n session token.\n\n - A callback of type\n [`GMSPlaceResultCallback`](/maps/documentation/places/ios-sdk/reference/objc/Type-Definitions#/c:GMSPlacesClient.h@T@GMSPlaceResultCallback)\n to handle the response.\n\n- The response contains a\n [`GMSPlace`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlace)\n instance containing details about the place. The values in the `types`\n property of the `GMSPlace` instance are now defined by\n [Table A](/maps/documentation/places/ios-sdk/place-types#table-a) and\n [Table B](/maps/documentation/places/ios-sdk/place-types#table-b).\n\n- The response `GMSPlace` instance contains the new `reviews`\n property of type [`GMSPlaceReview`](/maps/documentation/places/ios-sdk/refereference/objc/Classes/GMSPlaceReview).\n When your app displays information obtained from the `GMSPlace`\n instance, such as photos and reviews, the app must also display the required\n attributions.\n\n For more information, see the documentation on\n [attributions](/maps/documentation/places/ios-sdk/policies#other_attribution_requirements).\n- The response `GMSPlace` instance contains the following member functions:\n\n - [`isOpen`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlace#-isopen)\n calculates whether a place is open at the given time.\n\n - [`isOpenAtDate`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlace#-isopenatdate:)\n calculates whether a place is open on a given date.\n\n These functions are only available when you enable\n **Places SDK for iOS** . They are not available when you\n enable **Places SDK for iOS (New)** . For more information,\n see [Choose your SDK version](/maps/documentation/places/ios-sdk/choose-sdk).\n\nExample request\n---------------\n\nWith Place Details (New), you make a request and\npass all parameters in the `GMSFetchPlaceRequest` instance. This\nexample also uses a field mask so the response only includes the display name\nand website URL for the place: \n\n### Swift\n\n```swift\n// A hotel in Saigon with an attribution.\nlet placeID = \"ChIJV4k8_9UodTERU5KXbkYpSYs\"\n\n// Specify the place data types to return.\nlet fields = [GMSPlaceProperty.name, GMSPlaceProperty.website].map {$0.rawValue}\n\n// Create the GMSFetchPlaceRequest instance.\nlet fetchPlaceRequest = GMSFetchPlaceRequest(placeID: placeID, placeProperties: fields, sessionToken: nil)\n\nclient.fetchPlaceWithRequest(fetchPlaceRequest: fetchPlaceRequest, callback: {\n (place: GMSPlace?, error: Error?) in\n guard let place, error == nil else { return }\n print(\"Place found: \\(String(describing: place.name))\")\n})\n```\n\n### Objective-C\n\n```objective-c\n// A hotel in Saigon with an attribution.\nNSString *placeID = @\"ChIJV4k8_9UodTERU5KXbkYpSYs\";\n\n// Specify the place data types to return.\nNSArray\u003cNSString *\u003e *fields = @[GMSPlacePropertyName, GMSPlacePropertyWebsite];\n\n// Create the GMSFetchPlaceRequest instance.\nGMSFetchPlaceRequest *fetchPlaceRequest = [[GMSFetchPlaceRequest alloc] initWithPlaceID:placeID placeProperties: fields sessionToken:nil];\n\n[placesClient fetchPlaceWithRequest: fetchPlaceRequest callback: ^(GMSPlace *_Nullable place, NSError *_Nullable error) {\n if (error != nil) {\n NSLog(@\"An error occurred %@\", [error localizedDescription]);\n return;\n } else {\n NSLog(@\"Place Found: %@\", place.name);\n NSLog(@\"The place URL: %@\", place.website);\n }\n}];\n```"]]