تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
باستخدام حزمة تطوير برامج "الأماكن" لأجهزة iOS، يمكنك اكتشاف المكان الذي يقع فيه
الجهاز حاليًا. أي المكان الذي يقع فيه الموقع الجغرافي الذي تم الإبلاغ عنه حاليًا للجهاز. تشمل أمثلة الأماكن الأنشطة التجارية المحلية
ونقاط الاهتمام والمواقع الجغرافية.
إذا كان تطبيقك يستخدم
GMSPlacesClient findPlaceLikelihoodsFromCurrentLocationWithPlaceFields:،
يجب أن يطلب إذنًا لاستخدام خدمات الموقع الجغرافي. أضِف مفتاح
NSLocationWhenInUseUsageDescription إلى ملف Info.plist
لتحديد السلسلة التي تُعلم المستخدم بسبب حاجتك إلى خدمات تحديد الموقع الجغرافي. على سبيل المثال:
<key>NSLocationWhenInUseUsageDescription</key>
<string>Show your location on the map</string>
GMSPlaceField واحد أو أكثر لتحديد أنواع البيانات
التي سيتم عرضها في حال حذف هذه المَعلمة، سيتم عرض جميع الحقول المحتمَلة،
وسيتمّ إصدار فواتير لك وفقًا لذلك. لا ينطبق ذلك إلا على طلبات تفاصيل الأماكن.
طريقة ردّ اتصال لمعالجة النتائج
.
تتطابق الحقول مع نتائج البحث عن الأماكن، وتنقسم إلى ثلاث فئات للفوترة:
الأساسية وجهات الاتصال والجو. يتم تحصيل رسوم الاشتراك الأساسية مقابل الحقول الأساسية، ولا يتم تحصيل أي رسوم إضافية. يتم تحصيل رسوم أعلى مقابل حقول "جهة الاتصال" و"الجو". لمزيد من المعلومات
حول كيفية فوترة طلبات بيانات "الأماكن"، يُرجى الاطّلاع على
الاستخدام والفوترة.
تستدعي واجهة برمجة التطبيقات طريقة ردّ الاتصال المحدّدة، وتُرجع صفيفًا من عناصر
GMSPlaceLikelihood.
يمثّل كل كائن
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);}}}];
ملاحظات حول قيم الاحتمالية:
تقدّم احتمالية الظهور احتمالية نسبية
بأن يكون المكان هو أفضل مطابقة ضمن قائمة الأماكن المعروضة لطلب واحد. لا يمكنك مقارنة الاحتمالات على مستوى طلبات مختلفة.
ستكون قيمة الاحتمالية بين 0 و1.0.
يكون مجموع الاحتمالات في الصفيف الذي يتم إرجاعه من عناصر
GMSPlaceLikelihood
دائمًا أقل من أو يساوي 1.0. يُرجى العِلم أنّ المجموع ليس
بالضرورة 1.0.
على سبيل المثال، لتمثيل احتمالية بنسبة% 55 أنّ المكان الصحيح هو "الموقع أ"،
واحتمالة بنسبة% 35 أنّه "الموقع ب"، تتضمّن مصفوفة الاحتمالية عنصرَين:
"الموقع أ" بالاحتمالية 0.55
و"الموقع ب" بالاحتمالية 0.35.
تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-31 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],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)."]]