برای جستجوی مناطق و دریافت اطلاعات بیشتر در مورد مکانها، میتوانید از خدمات مکانها و API Geocoding با Maps SDK برای Android استفاده کنید. Places Service و Geocoding API جایگزین های قدرتمند و پایداری برای به دست آوردن شناسه مکان هستند. اگر قبلاً از شناسههای مکان استفاده میکنید، میتوانید از آن شناسهها با سبکهای مبتنی بر داده برای مرزها استفاده مجدد کنید.
به روشهای زیر سرویس Places و Geocoding را به Maps SDK برای برنامههای Android اضافه کنید:
Places SDK for Android یک کتابخانه اندرویدی است که حاوی روشهایی برای بازگرداندن اطلاعات مکانها است.
Places API اطلاعات مکانهایی را با استفاده از درخواستهای HTTP برمیگرداند.
کلاس ژئوکدر می تواند ژئوکد را به صورت پویا از ورودی کاربر معکوس کند.
Geocoding API به شما امکان می دهد آدرس های استاتیک و شناخته شده را ژئوکد کنید.
از سرویس مکان ها استفاده کنید
از جستجوی متن (جدید) برای یافتن شناسه مکان استفاده کنید
میتوانید از Text Search (جدید) REST API در Places API استفاده کنید تا با مشخص کردن places.id در فیلد ماسک، یک شناسه مکان که شامل دادههای منطقه است، دریافت کنید. استفاده از جستجوی متن (جدید) برای درخواست شناسه مکان فقط هزینه ای ندارد. بیشتر بدانید .
به عنوان مثال، برای دریافت شناسه مکان برای ترینیداد، کالیفرنیا، می توانید تماس API زیر را انجام دهید:
برای یافتن مناطق از تکمیل خودکار Places استفاده کنید
سرویس تکمیل خودکار مکانها در Places SDK برای Android راه مناسبی را برای امکان جستجوی مناطق به کاربران شما ارائه میکند. برای پیکربندی سرویس تکمیل خودکار Places برای برگرداندن فقط مناطق، از AutocompleteSupportFragment.setTypesFilter(List) استفاده کنید تا فیلتر نوع را روی PlaceTypes.REGIONS تنظیم کنید.
جزئیات مکان را برای یک منطقه دریافت کنید
سرویس جزئیات مکان در Places SDK برای Android دادههای یک منطقه را برمیگرداند میتواند بسیار مفید باشد. به عنوان مثال، شما می توانید:
شناسههای مکان مرزی را بر اساس نام مکانها جستجو کنید.
درگاه دید را برای بزرگنمایی به یک مرز دریافت کنید.
نوع ویژگی را برای مرز دریافت کنید (مثلاً locality ).
آدرس قالببندیشده را دریافت کنید، که به «نام مکان، ایالت، کشور» در منطقه ایالات متحده تبدیل میشود (به عنوان مثال، «Ottumwa، IA، USA»).
داده های مفید دیگری مانند عکس ها را دریافت کنید.
از Geocoding API استفاده کنید
Geocoding API به شما امکان می دهد یک آدرس را به مختصات طول و عرض جغرافیایی و یک شناسه مکان تبدیل کنید یا مختصات طول و عرض جغرافیایی یا شناسه مکان را به آدرس تبدیل کنید. کاربردهای زیر به خوبی با استایل داده محور برای مرزها ترکیب می شوند:
از Geocoding برای دریافت نمای یک منطقه استفاده کنید.
برای دریافت شناسه مکان برای مناطق اداری 1-4، محله، یا کد پستی، فیلتر مؤلفه را در تماس Geocoding خود اعمال کنید.
برای یافتن شناسه مکان ها بر اساس مختصات طول و عرض جغرافیایی، از کدگذاری جغرافیایی معکوس استفاده کنید، یا حتی شناسه مکان را برای همه اجزا در یک مکان خاص برگردانید.
مثال زیر از یک آدرس (url-escaped) برای درخواست به API Geocoding استفاده می کند:
برای پیدا کردن شناسههای مکان میتوانید از ژئوکدینگ معکوس استفاده کنید. مثال زیر تابع سرویس Geocoding شناسه های مکان را برای تمام اجزای آدرس در مختصات طول و عرض جغرافیایی مشخص شده برمی گرداند:
برای دریافت مولفه آدرس برای یک یا چند نوع از انواع زیر در محل مشخص شده، از ژئوکدینگ معکوس با فیلتر کردن مؤلفه استفاده کنید:
administrativeArea
country
locality
postalCode
تابع مثال بعدی استفاده از سرویس Geocoding را نشان میدهد که محدودیتهای مؤلفه را با کدگذاری جغرافیایی معکوس اضافه میکند تا همه اجزای آدرس را در مکان مشخص شده فقط برای نوع locality دریافت کنید:
تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eYou can use the Places Service and Geocoding API with the Maps SDK for Android to find place IDs for regions and get more information about them for data-driven styling.\u003c/p\u003e\n"],["\u003cp\u003eThe Places SDK for Android, Places API, and Geocoding API can be used to search for regions and retrieve their details, including place IDs, viewport, feature type, and formatted address.\u003c/p\u003e\n"],["\u003cp\u003eText Search (New) in the Places API, Places Autocomplete in the Places SDK for Android, and the Geocoding API are methods for obtaining place IDs.\u003c/p\u003e\n"],["\u003cp\u003eWhen using these services, be aware that the Places SDK for Android, Places API, and Geocoding API require enabling and are billed separately from the Maps SDK for Android.\u003c/p\u003e\n"]]],[],null,["# Use the Places Service and Geocoding API with data-driven styling for boundaries\n\nSelect platform: [Android](/maps/documentation/android-sdk/dds-boundaries/dds-use-maps-places-apis \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/dds-boundaries/dds-use-maps-places-apis \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/dds-boundaries/dds-use-maps-places-apis \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nYou can use the Places Service and the\nGeocoding API with the Maps SDK for Android to search for regions, and\nget more information about places. The Places Service\nand Geocoding API are powerful and stable alternatives for obtaining\nplace IDs. If you're already using place IDs, you can reuse those IDs with\ndata-driven styling for boundaries.\n\nAdd the Places Service and Geocoding to your\nMaps SDK for Android apps in the following ways:\n\n- [Places SDK for Android](/maps/documentation/places/android-sdk) is an Android library containing methods to returns information about places.\n- [Places API](/maps/documentation/places/web-service) returns information about places using HTTP requests.\n- [Geocoder class](https://developer.android.com/reference/android/location/Geocoder) can geocode and reverse geocode dynamically from user input.\n- [Geocoding API](/maps/documentation/geocoding) lets you geocode static, known addresses.\n\n| **Note:** The [Places SDK for Android](/maps/documentation/places/android-sdk), [Places API](/maps/documentation/places/web-service), and [Geocoding API](/maps/documentation/geocoding/cloud-setup) must be enabled, and are billed separately from the Maps SDK for Android.\n\nUse the Places Service\n----------------------\n\n### Use Text Search (New) to find a place ID\n\nYou can use [Text Search (New)](/maps/documentation/places/web-service/text-search)\nREST API in the Places API to get a place ID that includes region\ndata by specifying `places.id` in the field mask. Usage of the\nText Search (New) to request place IDs only incurs\nno charge. [Learn more](/maps/documentation/places/web-service/preview-billing).\n\nFor example, to get the place ID for Trinidad, CA you can make the following\nAPI call: \n\n```\ncurl -X POST -d '{\n \"textQuery\" : \"Trinidad, CA\"\n}' \\\n-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: \u003cvar translate=\"no\"\u003eAPI_KEY\u003c/var\u003e' \\\n-H 'X-Goog-FieldMask: places.id' \\\n'https://places.googleapis.com/v1/places:searchText'\n```\n\n### Use Places Autocomplete to find regions\n\nThe [Places Autocomplete](/maps/documentation/places/android-sdk/autocomplete)\nservice in the Places SDK for Android provides a convenient way to let\nyour users search for regions. To configure the Places Autocomplete service to\nreturn only regions, use\n[`AutocompleteSupportFragment.setTypesFilter(List)`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/AutocompleteSupportFragment#setTypesFilter(java.util.List%3Cjava.lang.String%3E))\nto set the type filter to `PlaceTypes.REGIONS`.\n\n### Get place details for a region\n\nThe [Place Details](/maps/documentation/places/android-sdk/place-details)\nservice in the Places SDK for Android returns data for a region can be\nquite useful. For example, you can:\n\n- Search for boundary place IDs based on place names.\n- Get the viewport for zooming to a boundary.\n- Get the feature type for the boundary (for example `locality`).\n- Get the formatted address, which resolves to \"Place Name, State, Country\" in the United States region (for example, \"Ottumwa, IA, USA\").\n- Get other useful data such as photos.\n\nUse the Geocoding API\n---------------------\n\nThe [Geocoding API](/maps/documentation/geocoding) lets you convert\nan address into latitude and longitude coordinates and a Place ID, or converts\nlatitude and longitude coordinates or a Place ID into an address. The following\nuses combine well with data-driven styling for boundaries:\n\n- Use Geocoding to get the viewport for a region.\n- Apply component filtering to your Geocoding call to get the place IDs for administrative areas 1-4, locality, or postal code.\n- Use reverse geocoding to find place IDs by latitude and longitude coordinates, or even return place IDs for all components in a particular location.\n\nThe following example uses an address (url-escaped) to make a request to the\nGeocoding API: \n\n```html\nhttps://maps.googleapis.com/maps/api/geocode/json?address=1600%20Amphitheatre%20Pkwy%20Mountain%20View%20CA&key=YOUR_API_KEY\n```\n\nYou can use [reverse geocoding](/maps/documentation/geocoding/requests-reverse-geocoding)\nto find place IDs. The following example Geocoding\nservice function returns the place IDs for all address components at the\nspecified latitude and longitude coordinates: \n\n```html\nhttps://maps.googleapis.com/maps/api/geocode/json?latlng=41.864182,-87.676930&key=YOUR_API_KEY\n```\n\nUse reverse geocoding with component filtering to get the address component\nfor one or more of the following types at the specified location:\n\n- `administrativeArea`\n- `country`\n- `locality`\n- `postalCode`\n\nThe next example function shows using the Geocoding service, adding component\nrestrictions with reverse geocoding to get all of the address components at the\nspecified location for only the `locality` type: \n\n```html\nhttps://maps.googleapis.com/maps/api/geocode/json?latlng=41.864182,-87.676930&result_type=locality&key=YOUR_API_KEY\n```"]]