반환할 데이터 유형을 지정하는 하나 이상의 GMSPlaceField 이 매개변수를 생략하면 가능한 모든 필드가 반환되며 그에 따라 요금이 청구됩니다. 이는 장소 세부정보 요청에만 적용됩니다.
결과를 처리하는 콜백 메서드입니다.
필드는 장소 검색 결과에 해당하며 기본, 연락처, 분위기 등 세 결제 카테고리로 분류됩니다. 기본 필드에는 기본 요율로 청구되며 추가 요금이 발생하지 않습니다. 연락처 및 분위기 필드에는 더 높은 요율로 청구됩니다. 장소 데이터 요청에 대해 요금이 청구되는 방법에 대한 자세한 내용은 사용량 및 결제를 참고하세요.
각 GMSPlaceLikelihood 객체는 장소를 나타냅니다. 장소별로 결과에는 장소가 올바른 장소일 가능성을 나타내는 표시가 포함됩니다. 값이 클수록 장소가 가장 일치할 가능성이 높습니다. 기기 위치에 해당하는 알려진 장소가 없는 경우 버퍼가 비어 있을 수 있습니다.
다음 코드 샘플은 기기가 있을 가능성이 가장 높은 장소 목록을 가져와 각 장소의 이름과 가능성을 로깅합니다.
Swift
// Specify the place data types to return.letfields:GMSPlaceField=GMSPlaceField(rawValue:UInt(GMSPlaceField.name.rawValue)|UInt(GMSPlaceField.placeID.rawValue))!placesClient?.findPlaceLikelihoodsFromCurrentLocation(withPlaceFields:fields,callback:{(placeLikelihoodList:Array<GMSPlaceLikelihood>?,error:Error?)inifleterror=error{print("An error occurred: \(error.localizedDescription)")return}ifletplaceLikelihoodList=placeLikelihoodList{forlikelihoodinplaceLikelihoodList{letplace=likelihood.placeprint("Current Place name \(String(describing:place.name)) at likelihood \(likelihood.likelihood)")print("Current PlaceID \(String(describing:place.placeID))")}}})
Objective-C
// Specify the place data types to return.GMSPlaceFieldfields=(GMSPlaceFieldName|GMSPlaceFieldPlaceID);[_placesClientfindPlaceLikelihoodsFromCurrentLocationWithPlaceFields:fieldscallback:^(NSArray<GMSPlaceLikelihood*>*_Nullablelikelihoods,NSError*_Nullableerror){if(error!=nil){NSLog(@"An error occurred %@",[errorlocalizedDescription]);return;}if(likelihoods!=nil){for(GMSPlaceLikelihood*likelihoodinlikelihoods){GMSPlace*place=likelihood.place;NSLog(@"Current place name: %@",place.name);NSLog(@"Place ID: %@",place.placeID);}}}];
유사도 값에 대한 유의 사항:
가능성은 단일 요청에 대해 반환된 장소 목록에서 장소가 가장 일치할 상대적 확률을 나타냅니다. 여러 요청 간에 가능성을 비교할 수는 없습니다.
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[],[],null,["# Current Place\n\nUsing the Places SDK for iOS, you can discover the place where the\ndevice is currently located. That is, the place at the device's\ncurrently-reported location. Examples of places include local businesses,\npoints of interest, and geographic locations.\n\n1. [Request location authorization](#permissions)\n2. [Usage limits](#quota)\n3. [Get the current location](#get-current)\n4. [Display attributions in your app](#attributions)\n\nRequesting location authorization\n---------------------------------\n\nIf your app uses\n[`GMSPlacesClient findPlaceLikelihoodsFromCurrentLocationWithPlaceFields:`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlacesClient#-findplacelikelihoodsfromcurrentlocationwithplacefields:callback:),\nyour app must request permission to use location services. Add the\n`NSLocationWhenInUseUsageDescription` key to your `Info.plist`\nfile, to define the string informing the user why you need the location\nservices. For example: \n\n```text\n\u003ckey\u003eNSLocationWhenInUseUsageDescription\u003c/key\u003e\n\u003cstring\u003eShow your location on the map\u003c/string\u003e\n```\n\nIf you want to call\n[`findPlaceLikelihoodsFromCurrentLocationWithPlaceFields:`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlacesClient#-findplacelikelihoodsfromcurrentlocationwithplacefields:callback:) when\nthe app is in the background, without triggering a confirmation dialog, take\nthe following steps prior to making the call:\n\n1. Add the `NSLocationAlwaysUsageDescription` key to your `Info.plist`file.\n2. Call `requestAlwaysAuthorization` on any instance of `CLLocationManager` before calling the method.\n\nRequest authorization from `CLLocationManager` as follows: \n\n### Swift\n\n```swift\n locationManager.requestAlwaysAuthorization()\n \n```\n\n### Objective-C\n\n```objective-c\n [self.locationManager requestAlwaysAuthorization];\n \n```\n\nGetting the current location\n----------------------------\n\n| **Note:** iOS 14 introduced a new privacy feature where users can choose to share their approximate, rather than precise, location. Check your app's value of [accuracyAuthorization](https://developer.apple.com/documentation/corelocation/cllocationmanager/3600215-accuracyauthorization) in `CLLocationManager` so your app behaves appropriately. [See this video for more information.](https://developer.apple.com/videos/play/wwdc2020/10162/)\n\nTo find the local business or other place where the device is currently\nlocated, call\n[`GMSPlacesClient\nfindPlaceLikelihoodsFromCurrentLocationWithPlaceFields:`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlacesClient#-findplacelikelihoodsfromcurrentlocationwithplacefields:callback:). Include\nthe following parameters:\n\n- One or more `GMSPlaceField`s, specifying which data types to return. If you omit this parameter, ALL possible fields will be returned, and you will be billed accordingly. This applies only to Place Details requests.\n- A callback method to handle the results.\n\n| **IMPORTANT!** `findPlaceLikelihoodsFromCurrentLocationWithPlaceFields:` does not support the following fields: `GMSPlaceFieldAddressComponents`, `GMSPlaceFieldOpeningHours`, `GMSPlaceFieldPhoneNumber`, and `GMSPlaceFieldWebsite`. Read more about [place data fields](/maps/documentation/places/ios-sdk/place-data-fields)\n\nFields correspond to Place Search results, and are divided into three billing categories:\nBasic, Contact, and Atmosphere. Basic fields are billed at base rate, and incur no additional\ncharges. Contact and Atmosphere fields are billed at a higher rate. For more information\nabout how Place data requests are billed, see\n[Usage and Billing](/maps/documentation/places/ios-sdk/usage-and-billing).\n\nThe API invokes the specified callback method, returning an array of\n[`GMSPlaceLikelihood`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlaceLikelihood)\nobjects.\n\nEach\n[`GMSPlaceLikelihood`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlaceLikelihood)\nobject represents a place. For each place, the result includes an\nindication of the likelihood that the place is the right one. A higher value\nmeans a greater probability that the place is the best match. The buffer may\nbe empty, if there is no known place corresponding to the device location.\n\nThe following code sample retrieves the list of places where the device is\nmost likely to be located, and logs the name and likelihood for each place. \n\n### Swift\n\n```swift\n// Specify the place data types to return.\nlet fields: GMSPlaceField = GMSPlaceField(rawValue: UInt(GMSPlaceField.name.rawValue) |\n UInt(GMSPlaceField.placeID.rawValue))!\nplacesClient?.findPlaceLikelihoodsFromCurrentLocation(withPlaceFields: fields, callback: {\n (placeLikelihoodList: Array\u003cGMSPlaceLikelihood\u003e?, error: Error?) in\n if let error = error {\n print(\"An error occurred: \\(error.localizedDescription)\")\n return\n }\n\n if let placeLikelihoodList = placeLikelihoodList {\n for likelihood in placeLikelihoodList {\n let place = likelihood.place\n print(\"Current Place name \\(String(describing: place.name)) at likelihood \\(likelihood.likelihood)\")\n print(\"Current PlaceID \\(String(describing: place.placeID))\")\n }\n }\n})\n```\n\n### Objective-C\n\n```objective-c\n// Specify the place data types to return.\nGMSPlaceField fields = (GMSPlaceFieldName | GMSPlaceFieldPlaceID);\n[_placesClient findPlaceLikelihoodsFromCurrentLocationWithPlaceFields:fields callback:^(NSArray\u003cGMSPlaceLikelihood *\u003e * _Nullable likelihoods, NSError * _Nullable error) {\n if (error != nil) {\n NSLog(@\"An error occurred %@\", [error localizedDescription]);\n return;\n }\n if (likelihoods != nil) {\n for (GMSPlaceLikelihood *likelihood in likelihoods) {\n GMSPlace *place = likelihood.place;\n NSLog(@\"Current place name: %@\", place.name);\n NSLog(@\"Place ID: %@\", place.placeID);\n }\n }\n}];\n```\n\nNotes about the likelihood values:\n\n- The likelihood provides a relative probability of the place being the best match within the list of returned places for a single request. You can't compare likelihoods across different requests.\n- The value of the likelihood will be between 0 and 1.0.\n- The sum of the likelihoods in a returned array of [`GMSPlaceLikelihood`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlaceLikelihood) objects is always less than or equal to 1.0. Note that the sum isn't necessarily 1.0.\n\nFor example, to represent a 55% likelihood that the correct place is Place A,\nand a 35% likelihood that it's Place B, the likelihood array has two members:\nPlace A with a likelihood of 0.55 and\nPlace B with a likelihood of 0.35.\n\nDisplaying attributions in your app\n-----------------------------------\n\nWhen your app displays information obtained from\n[`GMSPlacesClient\nfindPlaceLikelihoodsFromCurrentLocationWithPlaceFields:`](/maps/documentation/places/ios-sdk/reference/objc/Classes/GMSPlacesClient#-findplacelikelihoodsfromcurrentlocationwithplacefields:callback:), the app\nmust also display attributions. Read more about\n[attributions](/maps/documentation/places/ios-sdk/attributions)."]]